Show some error in filemanager if pasting fails
This commit is contained in:
@@ -117,10 +117,10 @@ export function createDirectoryModel(origin, accessToken, api) {
|
||||
await fetcher.del(`${origin}/api/v1/${api}/files/${filePath}`, { access_token: accessToken });
|
||||
},
|
||||
async rename(fromFilePath, toFilePath, overwrite = false) {
|
||||
await fetcher.put(`${origin}/api/v1/${api}/files/${fromFilePath}`, { action: 'rename', newFilePath: sanitize(toFilePath), overwrite }, { access_token: accessToken });
|
||||
return await fetcher.put(`${origin}/api/v1/${api}/files/${fromFilePath}`, { action: 'rename', newFilePath: sanitize(toFilePath), overwrite }, { access_token: accessToken });
|
||||
},
|
||||
async copy(fromFilePath, toFilePath) {
|
||||
await fetcher.put(`${origin}/api/v1/${api}/files/${fromFilePath}`, { action: 'copy', newFilePath: sanitize(toFilePath) }, { access_token: accessToken });
|
||||
return await fetcher.put(`${origin}/api/v1/${api}/files/${fromFilePath}`, { action: 'copy', newFilePath: sanitize(toFilePath) }, { access_token: accessToken });
|
||||
},
|
||||
async chown(filePath, uid) {
|
||||
await fetcher.put(`${origin}/api/v1/${api}/files/${filePath}`, { action: 'chown', uid: uid, recursive: true }, { access_token: accessToken });
|
||||
@@ -182,17 +182,18 @@ export function createDirectoryModel(origin, accessToken, api) {
|
||||
let done = false;
|
||||
let targetPath = targetDir + '/' + files[f].name;
|
||||
while (!done) {
|
||||
try {
|
||||
if (action === 'cut') await this.rename(this.buildFilePath(files[f].folderPath, files[f].name), targetPath);
|
||||
if (action === 'copy') await this.copy(this.buildFilePath(files[f].folderPath, files[f].name), targetPath);
|
||||
done = true;
|
||||
} catch (error) {
|
||||
if (error.status === 409) {
|
||||
targetPath += '-copy';
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
let result;
|
||||
if (action === 'cut') result = await this.rename(this.buildFilePath(files[f].folderPath, files[f].name), targetPath);
|
||||
if (action === 'copy') result = await this.copy(this.buildFilePath(files[f].folderPath, files[f].name), targetPath);
|
||||
|
||||
if (result.status === 404) {
|
||||
throw `Source file ${files[f].name} not found`;
|
||||
} else if (result.status === 409) {
|
||||
targetPath += '-copy';
|
||||
continue;
|
||||
}
|
||||
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user