Skip to content

Commit

Permalink
IconTextLampPlugin and IconTextPlugin /text topic wrongly removed the…
Browse files Browse the repository at this point in the history
… image file.
  • Loading branch information
BlueAndi committed Aug 15, 2024
1 parent 80aa173 commit 9a8dc1d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 38 deletions.
20 changes: 1 addition & 19 deletions lib/IconTextLampPlugin/src/IconTextLampPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,25 +188,7 @@ bool IconTextLampPlugin::setTopic(const String& topic, const JsonObjectConst& va
{
String iconFullPath = jsonIconFullPath.as<String>();

/* 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 == iconFullPath.isEmpty())
{
/* Rename uploaded icon by removing the file extension for temporary files. */
String iconFullPathWithoutTmp = iconFullPath.substring(0, iconFullPath.length() - strlen(FILE_EXT_TMP));

FILESYSTEM.rename(iconFullPath, iconFullPathWithoutTmp);

isSuccessful = loadIcon(iconFullPathWithoutTmp);
}
else
{
isSuccessful = true;
}
isSuccessful = loadIcon(iconFullPath);
}
}
else if (0U != topic.startsWith(String(TOPIC_LAMP) + "/"))
Expand Down
20 changes: 1 addition & 19 deletions lib/IconTextPlugin/src/IconTextPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,7 @@ bool IconTextPlugin::setTopic(const String& topic, const JsonObjectConst& value)
{
String iconFullPath = jsonIconFullPath.as<String>();

/* 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 == iconFullPath.isEmpty())
{
/* Rename uploaded icon by removing the file extension for temporary files. */
String iconFullPathWithoutTmp = iconFullPath.substring(0, iconFullPath.length() - strlen(FILE_EXT_TMP));

FILESYSTEM.rename(iconFullPath, iconFullPathWithoutTmp);

isSuccessful = loadIcon(iconFullPathWithoutTmp);
}
else
{
isSuccessful = true;
}
isSuccessful = loadIcon(iconFullPath);
}
}
else if (0U != topic.equals(TOPIC_ICON))
Expand Down

0 comments on commit 9a8dc1d

Please sign in to comment.