Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 23 additions & 34 deletions app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ public boolean isDirectory() {
}

public boolean isDirectory(Context context) {
boolean isDirectory;
switch (mode) {
case SFTP:
final Boolean returnValue =
Expand All @@ -634,56 +633,46 @@ public Boolean execute(@NonNull SFTPClient client) {

if (returnValue == null) {
LOG.error("Error obtaining if path is directory over SFTP");
return false;
}

//noinspection SimplifiableConditionalExpression
return returnValue == null ? false : returnValue;
return returnValue;
case SMB:
try {
isDirectory =
Single.fromCallable(() -> getSmbFile().isDirectory())
.subscribeOn(Schedulers.io())
.blockingGet();
return Single.fromCallable(() -> getSmbFile().isDirectory())
.subscribeOn(Schedulers.io())
.blockingGet();
} catch (Exception e) {
isDirectory = false;
LOG.warn("failed to get isDirectory with context for smb file", e);
return false;
}
break;
case FTP:
FTPFile ftpFile = getFtpFile();
isDirectory = ftpFile != null && ftpFile.isDirectory();
break;
case FILE:
isDirectory = getFile().isDirectory();
break;
return ftpFile != null && ftpFile.isDirectory();
case ROOT:
isDirectory = NativeOperations.isDirectory(path);
break;
return NativeOperations.isDirectory(path);
case DOCUMENT_FILE:
isDirectory = getDocumentFile(false).isDirectory();
break;
DocumentFile documentFile = getDocumentFile(false);
return documentFile != null && documentFile.isDirectory();
case OTG:
isDirectory = OTGUtil.getDocumentFile(path, context, false).isDirectory();
break;
DocumentFile otgFile = OTGUtil.getDocumentFile(path, context, false);
return otgFile != null && otgFile.isDirectory();
case DROPBOX:
case BOX:
case GDRIVE:
case ONEDRIVE:
isDirectory =
Single.fromCallable(
() ->
dataUtils
.getAccount(mode)
.getMetadata(CloudUtil.stripPath(mode, path))
.getFolder())
.subscribeOn(Schedulers.io())
.blockingGet();
break;
default:
isDirectory = getFile().isDirectory();
break;
return Single.fromCallable(
() ->
dataUtils
.getAccount(mode)
.getMetadata(CloudUtil.stripPath(mode, path))
.getFolder())
.subscribeOn(Schedulers.io())
.blockingGet();
default: // also handles the case `FILE`
File file = getFile();
return file != null && file.isDirectory();
}
return isDirectory;
}

/**
Expand Down