Skip to content

Commit

Permalink
Fix isDownloading for nested folders
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Jan 11, 2024
1 parent c396d2a commit a92e14a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@ class FileDownloadHelper {
return false
}

val fileStorageManager = FileDataStorageManager(user, MainApp.getAppContext().contentResolver)
val topParentId = fileStorageManager.getTopParentId(file)

return if (file.isFolder) {
backgroundJobManager.isStartFileDownloadJobScheduled(user, file.fileId)
backgroundJobManager.isStartFileDownloadJobScheduled(user, file.fileId) ||
backgroundJobManager.isStartFileDownloadJobScheduled(user, topParentId)
} else {
FileDownloadWorker.isDownloading(user.accountName, file.fileId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,27 @@ public boolean fileExists(String path) {
return fileDao.getFileByEncryptedRemotePath(path, user.getAccountName()) != null;
}

public long getTopParentId(OCFile file) {
if (file.getParentId() == 1) {
return file.getFileId();
}

return getTopParentIdRecursive(file);
}

private long getTopParentIdRecursive(OCFile file) {
if (file.getParentId() == 1) {
return file.getFileId();
}

OCFile parentFile = getFileById(file.getParentId());
if (parentFile != null) {
return getTopParentId(parentFile);
}

return file.getFileId();
}

public List<OCFile> getAllFilesRecursivelyInsideFolder(OCFile file) {
ArrayList<OCFile> result = new ArrayList<>();

Expand Down

0 comments on commit a92e14a

Please sign in to comment.