deleteSubDirIfParentPathMatches

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2024-08-27 12:02:34 +02:00
parent a83ab214ce
commit 03ea98c3e0
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
2 changed files with 11 additions and 0 deletions

View file

@ -12,6 +12,16 @@ import com.nextcloud.client.database.entity.OfflineOperationEntity
private const val DELIMITER = '/'
fun OfflineOperationDao.deleteSubDirIfParentPathMatches(path: String) {
val topDir = path.getParentPathFromPath()
getAll().forEach {
val entityTopDir = it.getParentPathFromPath()
if (entityTopDir == topDir) {
delete(it)
}
}
}
fun OfflineOperationDao.updatePathsIfParentPathMatches(oldPath: String?, newTopDir: String?, parentPath: String?) {
if (oldPath.isNullOrEmpty() || newTopDir.isNullOrEmpty()) return

View file

@ -156,6 +156,7 @@ public class FileDataStorageManager {
}
public void deleteOfflineOperation(OCFile file) {
OfflineOperationExtensionsKt.deleteSubDirIfParentPathMatches(offlineOperationDao, file.getDecryptedRemotePath());
offlineOperationDao.deleteByPath(file.getDecryptedRemotePath());
removeFile(file, true, true);
}