Skip to content

Commit

Permalink
Add file existence check
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <alper_ozturk@proton.me>
  • Loading branch information
alperozturk96 committed Sep 26, 2024
1 parent ab1b67b commit 26cbf21
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ class InternalTwoWaySyncWork(
val folders = fileDataStorageManager.getInternalTwoWaySyncFolders(user)

for (folder in folders) {
val freeSpaceLeft = File(folder.storagePath).getFreeSpace()
val localFolderSize = FileStorageUtils.getFolderSize(File(folder.storagePath, MainApp.getDataFolder()))
val remoteFolderSize = folder.fileLength
val file = File(folder.storagePath)
if (file.exists()) {
val freeSpaceLeft = file.getFreeSpace()
val localFolder = File(folder.storagePath, MainApp.getDataFolder())
val localFolderSize = FileStorageUtils.getFolderSize(localFolder)
val remoteFolderSize = folder.fileLength

if (freeSpaceLeft < (remoteFolderSize - localFolderSize)) {
Log_OC.d(TAG, "Not enough space left!")
result = false
if (freeSpaceLeft < (remoteFolderSize - localFolderSize)) {
Log_OC.d(TAG, "Not enough space left!")
return Result.failure()
}
}

Log_OC.d(TAG, "Folder ${folder.remotePath}: started!")
Expand Down

0 comments on commit 26cbf21

Please sign in to comment.