Skip to content

Commit

Permalink
Bugfix: Uploaded icons were not handled correct in IconTextLampPlugin…
Browse files Browse the repository at this point in the history
… and IconTextPlugin.
  • Loading branch information
BlueAndi committed Aug 15, 2024
1 parent 31e8fb9 commit f348bc8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
20 changes: 19 additions & 1 deletion lib/IconTextLampPlugin/src/IconTextLampPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,25 @@ bool IconTextLampPlugin::setTopic(const String& topic, const JsonObjectConst& va
{
String fullPath = jsonFullPath.as<String>();

isSuccessful = loadIcon(fullPath);
/* Clear always the icon indpended whether its requested by user.
* In case of an uploaded new icon, clearing will close the image
* file and makes it possible to overwrite the file.
*/
clearIcon();

if (false == fullPath.isEmpty())
{
/* Rename uploaded icon by removing the file extension for temporary files. */
String iconFullPathWithoutTmp = fullPath.substring(0, fullPath.length() - strlen(FILE_EXT_TMP));

FILESYSTEM.rename(fullPath, iconFullPathWithoutTmp);

isSuccessful = loadIcon(iconFullPathWithoutTmp);
}
else
{
isSuccessful = true;
}
}
}
else
Expand Down
20 changes: 19 additions & 1 deletion lib/IconTextPlugin/src/IconTextPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,25 @@ bool IconTextPlugin::setTopic(const String& topic, const JsonObjectConst& value)
{
String fullPath = jsonFullPath.as<String>();

isSuccessful = loadIcon(fullPath);
/* Clear always the icon indpended whether its requested by user.
* In case of an uploaded new icon, clearing will close the image
* file and makes it possible to overwrite the file.
*/
clearIcon();

if (false == fullPath.isEmpty())
{
/* Rename uploaded icon by removing the file extension for temporary files. */
String iconFullPathWithoutTmp = fullPath.substring(0, fullPath.length() - strlen(FILE_EXT_TMP));

FILESYSTEM.rename(fullPath, iconFullPathWithoutTmp);

isSuccessful = loadIcon(iconFullPathWithoutTmp);
}
else
{
isSuccessful = true;
}
}
}
else
Expand Down

0 comments on commit f348bc8

Please sign in to comment.