Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
Commented out Cloud related code to keep app compile first
  • Loading branch information
TranceLove committed Sep 7, 2024
1 parent ba93d8f commit 5d1791c
Show file tree
Hide file tree
Showing 13 changed files with 574 additions and 593 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,15 @@ private boolean doDeleteFile(@NonNull HybridFileParcelable file) throws Exceptio
case BOX:
case GDRIVE:
case ONEDRIVE:
CloudStorage cloudStorage = dataUtils.getAccount(file.getMode());
try {
cloudStorage.delete(CloudUtil.stripPath(file.getMode(), file.getPath()));
return true;
} catch (Exception e) {
LOG.warn("failed to delete cloud files", e);
return false;
}
return false;
// CloudStorage cloudStorage = dataUtils.getAccount(file.getMode());
// try {
// cloudStorage.delete(CloudUtil.stripPath(file.getMode(), file.getPath()));
// return true;
// } catch (Exception e) {
// LOG.warn("failed to delete cloud files", e);
// return false;
// }
default:
try {
/* SMB and SFTP (or any remote files that may support in the future) should not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,16 +761,16 @@ private List<LayoutElementParcelable> listCloud(
if (cloudCache != null && !forceReload) {
list = cloudCache;
} else {
CloudStorage cloudStorage = dataUtils.getAccount(openmode);
// CloudStorage cloudStorage = dataUtils.getAccount(openmode);
list = new ArrayList<>();
listCloudInternal(
path,
cloudStorage,
openmode,
file -> {
LayoutElementParcelable elem = createListParcelables(file);
if (elem != null) list.add(elem);
});
// listCloudInternal(
// path,
// cloudStorage,
// openmode,
// file -> {
// LayoutElementParcelable elem = createListParcelables(file);
// if (elem != null) list.add(elem);
// });
mainActivityViewModel.putInCache(path, list);
}
return list;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,24 @@ private MoveFilesReturn processFile(
case BOX:
case ONEDRIVE:
case GDRIVE:
DataUtils dataUtils = DataUtils.getInstance();

CloudStorage cloudStorage = dataUtils.getAccount(mode);
if (baseFile.getMode() == mode) {
// source and target both in same filesystem, use API method
try {
cloudStorage.move(
CloudUtil.stripPath(mode, baseFile.getPath()), CloudUtil.stripPath(mode, destPath));
} catch (RuntimeException e) {
LOG.warn("failed to move file in cloud filesystem", e);
return new MoveFilesReturn(false, false, destinationSize, totalBytes);
}
} else {
// not in same filesystem, execute service
return new MoveFilesReturn(false, false, destinationSize, totalBytes);
}
default:
return new MoveFilesReturn(false, false, destinationSize, totalBytes);
// DataUtils dataUtils = DataUtils.getInstance();
//
// CloudStorage cloudStorage = dataUtils.getAccount(mode);
// if (baseFile.getMode() == mode) {
// // source and target both in same filesystem, use API method
// try {
// cloudStorage.move(
// CloudUtil.stripPath(mode, baseFile.getPath()), CloudUtil.stripPath(mode, destPath));
// } catch (RuntimeException e) {
// LOG.warn("failed to move file in cloud filesystem", e);
// return new MoveFilesReturn(false, false, destinationSize, totalBytes);
// }
// } else {
// // not in same filesystem, execute service
// return new MoveFilesReturn(false, false, destinationSize, totalBytes);
// }
// default:
// return new MoveFilesReturn(false, false, destinationSize, totalBytes);
}

return null;
Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/amaze/filemanager/filesystem/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,12 @@ public static final void writeUriToStorage(
case BOX:
case ONEDRIVE:
case GDRIVE:
OpenMode mode = hFile.getMode();

CloudStorage cloudStorage = dataUtils.getAccount(mode);
String path = CloudUtil.stripPath(mode, finalFilePath);
cloudStorage.upload(path, bufferedInputStream, documentFile.length(), true);
retval.add(path);
// OpenMode mode = hFile.getMode();
//
// CloudStorage cloudStorage = dataUtils.getAccount(mode);
// String path = CloudUtil.stripPath(mode, finalFilePath);
// cloudStorage.upload(path, bufferedInputStream, documentFile.length(), true);
// retval.add(path);
break;
case OTG:
DocumentFile documentTargetFile =
Expand Down
66 changes: 34 additions & 32 deletions app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import static com.amaze.filemanager.filesystem.ssh.SFTPClientExtKt.READ_AHEAD_MAX_UNCONFIRMED_READS;
import static com.amaze.filemanager.filesystem.ssh.SshClientUtils.sftpGetSize;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -848,10 +849,10 @@ public long getUsableSpace() {
case BOX:
case GDRIVE:
case ONEDRIVE:
SpaceAllocation spaceAllocation =
((OmhStorageEntity.OmhFolder) dataUtils.getAccount(mode).getOmhStorageEntity())
.get.getAllocation();
size = spaceAllocation.getTotal() - spaceAllocation.getUsed();
// SpaceAllocation spaceAllocation =
// ((OmhStorageEntity.OmhFolder) dataUtils.getAccount(mode).getOmhStorageEntity())
// .get.getAllocation();
// size = spaceAllocation.getTotal() - spaceAllocation.getUsed();
break;
case SFTP:
final Long returnValue =
Expand Down Expand Up @@ -916,7 +917,7 @@ public Long execute(@NonNull SFTPClient client) throws IOException {

/** Gets total size of the disk */
public long getTotal(Context context) {
long size = 0l;
long size = 0L;
switch (mode) {
case SMB:
// TODO: Find total storage space of SMB when JCIFS adds support
Expand All @@ -936,8 +937,8 @@ public long getTotal(Context context) {
case BOX:
case ONEDRIVE:
case GDRIVE:
SpaceAllocation spaceAllocation = dataUtils.getAccount(mode).getAllocation();
size = spaceAllocation.getTotal();
// SpaceAllocation spaceAllocation = dataUtils.getAccount(mode).getAllocation();
// size = spaceAllocation.getTotal();
break;
case SFTP:
final Long returnValue =
Expand Down Expand Up @@ -1066,11 +1067,11 @@ public FTPFile[] executeWithFtpClient(@NonNull FTPClient ftpClient)
case BOX:
case GDRIVE:
case ONEDRIVE:
try {
CloudUtil.getCloudFiles(path, dataUtils.getAccount(mode), mode, onFileFound);
} catch (CloudPluginException e) {
LOG.warn("failed to get children file for cloud file", e);
}
// try {
// CloudUtil.getCloudFiles(path, dataUtils.getAccount(mode), mode, onFileFound);
// } catch (CloudPluginException e) {
// LOG.warn("failed to get children file for cloud file", e);
// }
break;
case TRASH_BIN:
default:
Expand Down Expand Up @@ -1220,9 +1221,10 @@ public InputStream executeWithFtpClient(@NonNull FTPClient ftpClient)
case BOX:
case GDRIVE:
case ONEDRIVE:
CloudStorage cloudStorageOneDrive = dataUtils.getAccount(mode);
// CloudStorage cloudStorageOneDrive = dataUtils.getAccount(mode);
LOG.debug(CloudUtil.stripPath(mode, path));
inputStream = cloudStorageOneDrive.download(CloudUtil.stripPath(mode, path));
// inputStream = cloudStorageOneDrive.download(CloudUtil.stripPath(mode, path));
inputStream = new ByteArrayInputStream(new byte[0]);
break;
case TRASH_BIN:
default:
Expand Down Expand Up @@ -1360,18 +1362,18 @@ public Boolean execute(SFTPClient client) throws IOException {
else {
exists = getFtpFile() != null;
}
} else if (isDropBoxFile()) {
CloudStorage cloudStorageDropbox = dataUtils.getAccount(OpenMode.DROPBOX);
exists = cloudStorageDropbox.exists(CloudUtil.stripPath(OpenMode.DROPBOX, path));
} else if (isBoxFile()) {
CloudStorage cloudStorageBox = dataUtils.getAccount(OpenMode.BOX);
exists = cloudStorageBox.exists(CloudUtil.stripPath(OpenMode.BOX, path));
} else if (isGoogleDriveFile()) {
CloudStorage cloudStorageGoogleDrive = dataUtils.getAccount(OpenMode.GDRIVE);
exists = cloudStorageGoogleDrive.exists(CloudUtil.stripPath(OpenMode.GDRIVE, path));
} else if (isOneDriveFile()) {
CloudStorage cloudStorageOneDrive = dataUtils.getAccount(OpenMode.ONEDRIVE);
exists = cloudStorageOneDrive.exists(CloudUtil.stripPath(OpenMode.ONEDRIVE, path));
// } else if (isDropBoxFile()) {
// CloudStorage cloudStorageDropbox = dataUtils.getAccount(OpenMode.DROPBOX);
// exists = cloudStorageDropbox.exists(CloudUtil.stripPath(OpenMode.DROPBOX, path));
// } else if (isBoxFile()) {
// CloudStorage cloudStorageBox = dataUtils.getAccount(OpenMode.BOX);
// exists = cloudStorageBox.exists(CloudUtil.stripPath(OpenMode.BOX, path));
// } else if (isGoogleDriveFile()) {
// CloudStorage cloudStorageGoogleDrive = dataUtils.getAccount(OpenMode.GDRIVE);
// exists = cloudStorageGoogleDrive.exists(CloudUtil.stripPath(OpenMode.GDRIVE, path));
// } else if (isOneDriveFile()) {
// CloudStorage cloudStorageOneDrive = dataUtils.getAccount(OpenMode.ONEDRIVE);
// exists = cloudStorageOneDrive.exists(CloudUtil.stripPath(OpenMode.ONEDRIVE, path));
} else if (isLocal()) {
exists = getFile().exists();
} else if (isRoot()) {
Expand Down Expand Up @@ -1536,12 +1538,12 @@ public Boolean executeWithFtpClient(@NonNull FTPClient ftpClient) throws IOExcep
}
}
} else if (isCloudDriveFile()) {
CloudStorage cloudStorageDropbox = dataUtils.getAccount(mode);
try {
cloudStorageDropbox.createFolder(CloudUtil.stripPath(mode, path));
} catch (Exception e) {
LOG.warn("failed to create folder for cloud file", e);
}
// CloudStorage cloudStorageDropbox = dataUtils.getAccount(mode);
// try {
// cloudStorageDropbox.createFolder(CloudUtil.stripPath(mode, path));
// } catch (Exception e) {
// LOG.warn("failed to create folder for cloud file", e);
// }
} else if (isTrashBin()) { // do nothing
} else MakeDirectoryOperation.mkdirs(context, this);
}
Expand Down
Loading

0 comments on commit 5d1791c

Please sign in to comment.