Skip to content

Commit

Permalink
handle folder deletion more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
kevodwyer committed Nov 21, 2024
1 parent e603cbd commit a7398e5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/i18n/en-GB.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module.exports = {
"DRIVE.DELETE.CONFIRM":"Are you sure you want to delete $COUNT items?",
"DRIVE.DELETE.FILE.ERROR":"Error deleting file: $NAME: $MESSAGE",
"DRIVE.INSTALL_DEDICATED_APP":"There is no app installed for this kind of file, please install an app to open",
"DRIVE.MISSING.FOLDER":"Folder not found!",
"APPNAV.LAUNCHER":"Launcher",
"APPNAV.DRIVE":"Drive",
"APPNAV.NEWSFEED":"Newsfeed",
Expand Down
25 changes: 20 additions & 5 deletions src/views/Drive.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1342,24 +1342,39 @@ module.exports = {
var path = this.getPath;
var that = this;
this.context.getByPath(path).thenApply(function (fileOpt) {
let file = fileOpt.ref;
if (file != null) {
if (fileOpt.isPresent()) {
let file = fileOpt.get();
file.getLatest(that.context.network).thenApply(updated => {
if (! updated.isDirectory()) {
// go to parent if we tried to navigate to file
if (path.endsWith("/"))
path = path.substring(0, path.length-1)
let index = path.lastIndexOf("/");
filename = path.substring(index+1);
that.changePath(path.substring(0, index));
that.updateCurrentDirectory(selectedFilename, callback)
that.updateCurrentDirectory(selectedFilename, callback);
return;
}
that.currentDir = updated;
that.updateFiles(selectedFilename, callback);
}).exceptionally(function (throwable) {
console.log("Unable to get updated folder. Error: " + throwable.getMessage());
that.$toast.error(that.translate("DRIVE.MISSING.FOLDER"));
if (!that.isSecretLink && path.startsWith("/" + that.context.username)) {
if (path.endsWith("/"))
path = path.substring(0, path.length-1)
let index = path.lastIndexOf("/");
that.changePath(path.substring(0, index));
that.updateCurrentDirectory(selectedFilename, callback);
}
});
} else {
that.$toast.error(that.translate("DRIVE.MISSING.FOLDER"));
if (!that.isSecretLink && path.startsWith("/" + that.context.username)) {
if (path.endsWith("/"))
path = path.substring(0, path.length-1)
let index = path.lastIndexOf("/");
that.changePath(path.substring(0, index));
that.updateCurrentDirectory(selectedFilename, callback);
}
}
}).exceptionally(function (throwable) {
console.log(throwable.getMessage());
Expand Down

0 comments on commit a7398e5

Please sign in to comment.