fix: move() only rename if relocationResult has different name than target

This commit is contained in:
Manuel Jenny 2021-03-17 07:04:57 +01:00
parent 46dbde1103
commit 615fe5558e
No known key found for this signature in database
GPG Key ID: 1C80FE62B2BEAA18

View File

@ -214,12 +214,15 @@ class PCloudImpl {
}
if (source instanceof PCloudFolder) {
//TODO: check if this can be reached at all
relocationResult = client().moveFolder(source.getId(), target.getParent().getId()).execute();
relocationResult = client().renameFolder(relocationResult.asFolder(), target.getName()).execute();
if (!relocationResult.name().equals(target.getName())) {
relocationResult = client().renameFolder(relocationResult.asFolder(), target.getName()).execute();
}
} else {
relocationResult = client().moveFile(source.getId(), target.getParent().getId()).execute().asFile();
relocationResult = client().renameFile(relocationResult.asFile(), target.getName()).execute();
relocationResult = client().moveFile(source.getId(), target.getParent().getId()).execute();
if (!relocationResult.name().equals(target.getName())) {
relocationResult = client().renameFile(relocationResult.asFile(), target.getName()).execute();
}
}
idCache.remove(source);