Skip to content

Commit

Permalink
Fix GpxDataItem update after file rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Chumva committed Jul 26, 2023
1 parent d2f0afe commit 72855dc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions OsmAnd/src/net/osmand/plus/track/helpers/GpxDbHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,18 @@ private GpxDataItem putToCache(@NonNull GpxDataItem item) {
return itemsCache.put(item.getFile(), item);
}

private void removeFromCache(@NonNull GpxDataItem item) {
itemsCache.remove(item.getFile());
private void removeFromCache(@NonNull File file) {
itemsCache.remove(file);
}

public boolean rename(@NonNull File currentFile, @NonNull File newFile) {
GpxDataItem item = itemsCache.get(currentFile);
return database.rename(item, currentFile, newFile);
boolean res = database.rename(item, currentFile, newFile);
if (item != null) {
putToCache(item);
removeFromCache(currentFile);
}
return res;
}

public boolean updateColor(@NonNull GpxDataItem item, int color) {
Expand Down

0 comments on commit 72855dc

Please sign in to comment.