+ omit sub-dirs in makeListDeleted.

no need to run rm -r for every sub-dir
pull/1/head
Ivan Olexyn 5 years ago
parent 27db1e2890
commit 3c19f1cf97

@ -116,6 +116,23 @@ public class SyncDirectory {
listDeleted = tools.mapMinus(fromA, substractB); listDeleted = tools.mapMinus(fromA, substractB);
Map<String, SyncFile> swap = new HashMap<>();
for (var entry : listDeleted.entrySet()) {
String key = entry.getKey();
String parentKey = entry.getValue().getParent();
if (listDeleted.containsKey(parentKey) || swap.containsKey(parentKey)) {
swap.put(key, listDeleted.get(key));
}
}
listDeleted = tools.mapMinus(listDeleted, swap);
} }
@ -133,7 +150,7 @@ public class SyncDirectory {
String freshFileKey = freshFileEntry.getKey(); String freshFileKey = freshFileEntry.getKey();
SyncFile freshFile = freshFileEntry.getValue(); SyncFile freshFile = freshFileEntry.getValue();
if(freshFile.isDirectory()){ continue;} // no need to modify Directories, the Filesystem will do that, if a File changed. if (freshFile.isDirectory()) { continue;} // no need to modify Directories, the Filesystem will do that, if a File changed.
// If KEY exists in OLD , thus FILE was NOT created. // If KEY exists in OLD , thus FILE was NOT created.
if (stateFileMap.containsKey(freshFileKey)) { if (stateFileMap.containsKey(freshFileKey)) {
@ -193,11 +210,6 @@ public class SyncDirectory {
this.otherParentFile = new File(otherParentPath); this.otherParentFile = new File(otherParentPath);
} }
} }
@ -225,7 +237,7 @@ public class SyncDirectory {
*/ */
public void doDelete() { public void doDelete() {
for (var entry: listDeleted.entrySet()) { for (var entry : listDeleted.entrySet()) {
SyncFile deletedFile = entry.getValue(); SyncFile deletedFile = entry.getValue();
for (var otherEntry : syncMap.syncDirectories.entrySet()) { for (var otherEntry : syncMap.syncDirectories.entrySet()) {
@ -241,7 +253,7 @@ public class SyncDirectory {
} }
} }
private void deleteFile(Info info, SyncDirectory thisSD, SyncFile thisFile, SyncDirectory otherSD){ private void deleteFile(Info info, SyncDirectory thisSD, SyncFile thisFile, SyncDirectory otherSD) {
SyncFile otherFile = new SyncFile(otherSD, otherSD.path + thisFile.relativePath); SyncFile otherFile = new SyncFile(otherSD, otherSD.path + thisFile.relativePath);
@ -298,7 +310,6 @@ public class SyncDirectory {
} }
} }

Loading…
Cancel
Save