MOBILE-2915 file: Fix delete files with special chars
parent
ba27f75324
commit
9978bd0cae
|
@ -62,13 +62,6 @@ export class CoreLocalFileComponent implements OnInit {
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.manage = this.utils.isTrueOrOne(this.manage);
|
this.manage = this.utils.isTrueOrOne(this.manage);
|
||||||
|
|
||||||
// Let's calculate the relative path for the file.
|
|
||||||
this.relativePath = this.fileProvider.removeBasePath(this.file.toURL());
|
|
||||||
if (!this.relativePath) {
|
|
||||||
// Didn't find basePath, use fullPath but if the user tries to manage the file it'll probably fail.
|
|
||||||
this.relativePath = this.file.fullPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loadFileBasicData();
|
this.loadFileBasicData();
|
||||||
|
|
||||||
// Get the size and timemodified.
|
// Get the size and timemodified.
|
||||||
|
@ -88,6 +81,13 @@ export class CoreLocalFileComponent implements OnInit {
|
||||||
this.fileName = this.file.name;
|
this.fileName = this.file.name;
|
||||||
this.fileIcon = this.mimeUtils.getFileIcon(this.file.name);
|
this.fileIcon = this.mimeUtils.getFileIcon(this.file.name);
|
||||||
this.fileExtension = this.mimeUtils.getFileExtension(this.file.name);
|
this.fileExtension = this.mimeUtils.getFileExtension(this.file.name);
|
||||||
|
|
||||||
|
// Let's calculate the relative path for the file.
|
||||||
|
this.relativePath = this.fileProvider.removeBasePath(this.file.toURL());
|
||||||
|
if (!this.relativePath) {
|
||||||
|
// Didn't find basePath, use fullPath but if the user tries to manage the file it'll probably fail.
|
||||||
|
this.relativePath = this.file.fullPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -324,7 +324,16 @@ export class CoreFileProvider {
|
||||||
path = this.removeStartingSlash(path.replace(this.basePath, ''));
|
path = this.removeStartingSlash(path.replace(this.basePath, ''));
|
||||||
this.logger.debug('Remove file: ' + path);
|
this.logger.debug('Remove file: ' + path);
|
||||||
|
|
||||||
return this.file.removeFile(this.basePath, path);
|
return this.file.removeFile(this.basePath, path).catch((error) => {
|
||||||
|
// The delete can fail if the path has encoded characters. Try again if that's the case.
|
||||||
|
const decodedPath = decodeURI(path);
|
||||||
|
|
||||||
|
if (decodedPath != path) {
|
||||||
|
return this.file.removeFile(this.basePath, decodedPath);
|
||||||
|
} else {
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue