mirror of
https://github.com/drakkan/sftpgo.git
synced 2024-11-21 23:20:24 +00:00
WebClient: improve error message when trying to move non-empty folder
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
5a319dc64f
commit
d92f85d1dd
7 changed files with 24 additions and 13 deletions
|
@ -1728,9 +1728,9 @@ func (c *BaseConnection) GetGenericError(err error) error {
|
|||
}
|
||||
return sftp.ErrSSHFxFailure
|
||||
default:
|
||||
if err == ErrPermissionDenied || err == ErrNotExist || err == ErrOpUnsupported ||
|
||||
err == ErrQuotaExceeded || err == ErrReadQuotaExceeded || err == vfs.ErrStorageSizeUnavailable ||
|
||||
err == ErrShuttingDown {
|
||||
if errors.Is(err, ErrPermissionDenied) || errors.Is(err, ErrNotExist) || errors.Is(err, ErrOpUnsupported) ||
|
||||
errors.Is(err, ErrQuotaExceeded) || errors.Is(err, ErrReadQuotaExceeded) ||
|
||||
errors.Is(err, vfs.ErrStorageSizeUnavailable) || errors.Is(err, ErrShuttingDown) {
|
||||
return err
|
||||
}
|
||||
c.Log(logger.LevelError, "generic error: %+v", err)
|
||||
|
|
|
@ -482,7 +482,7 @@ func (*AzureBlobFs) IsNotSupported(err error) bool {
|
|||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return err == ErrVfsUnsupported
|
||||
return errors.Is(err, ErrVfsUnsupported)
|
||||
}
|
||||
|
||||
func (*AzureBlobFs) isBadRequestError(err error) bool {
|
||||
|
@ -782,7 +782,7 @@ func (fs *AzureBlobFs) renameInternal(source, target string, fi os.FileInfo, rec
|
|||
return numFiles, filesSize, err
|
||||
}
|
||||
if hasContents {
|
||||
return numFiles, filesSize, fmt.Errorf("cannot rename non empty directory: %q", source)
|
||||
return numFiles, filesSize, fmt.Errorf("%w: cannot rename non empty directory: %q", ErrVfsUnsupported, source)
|
||||
}
|
||||
}
|
||||
if err := fs.mkdirInternal(target); err != nil {
|
||||
|
|
|
@ -19,6 +19,7 @@ package vfs
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime"
|
||||
|
@ -448,7 +449,7 @@ func (*GCSFs) IsNotSupported(err error) bool {
|
|||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return err == ErrVfsUnsupported
|
||||
return errors.Is(err, ErrVfsUnsupported)
|
||||
}
|
||||
|
||||
// CheckRootPath creates the specified local root directory if it does not exists
|
||||
|
@ -774,7 +775,7 @@ func (fs *GCSFs) renameInternal(source, target string, fi os.FileInfo, recursion
|
|||
return numFiles, filesSize, err
|
||||
}
|
||||
if hasContents {
|
||||
return numFiles, filesSize, fmt.Errorf("cannot rename non empty directory: %q", source)
|
||||
return numFiles, filesSize, fmt.Errorf("%w: cannot rename non empty directory: %q", ErrVfsUnsupported, source)
|
||||
}
|
||||
}
|
||||
if err := fs.mkdirInternal(target); err != nil {
|
||||
|
|
|
@ -482,7 +482,7 @@ func (*S3Fs) IsNotSupported(err error) bool {
|
|||
if err == nil {
|
||||
return false
|
||||
}
|
||||
return err == ErrVfsUnsupported
|
||||
return errors.Is(err, ErrVfsUnsupported)
|
||||
}
|
||||
|
||||
// CheckRootPath creates the specified local root directory if it does not exists
|
||||
|
@ -700,7 +700,7 @@ func (fs *S3Fs) renameInternal(source, target string, fi os.FileInfo, recursion
|
|||
return numFiles, filesSize, err
|
||||
}
|
||||
if hasContents {
|
||||
return numFiles, filesSize, fmt.Errorf("cannot rename non empty directory: %q", source)
|
||||
return numFiles, filesSize, fmt.Errorf("%w: cannot rename non empty directory: %q", ErrVfsUnsupported, source)
|
||||
}
|
||||
}
|
||||
if err := fs.mkdirInternal(target); err != nil {
|
||||
|
|
|
@ -328,7 +328,8 @@
|
|||
"err_generic": "Error moving files/directories",
|
||||
"err_403": "$t(fs.move.err_generic). $t(fs.err_403)",
|
||||
"err_429": "$t(fs.move.err_generic). $t(fs.err_429)",
|
||||
"err_exists": "$t(fs.move.err_generic). $t(fs.err_exists)"
|
||||
"err_exists": "$t(fs.move.err_generic). $t(fs.err_exists)",
|
||||
"err_unsupported": "Unsupported: if you want to move a directory make sure it is empty"
|
||||
},
|
||||
"rename": {
|
||||
"title": "Rename \"{{- name}}\"",
|
||||
|
@ -336,7 +337,8 @@
|
|||
"err_generic": "Unable to rename \"{{- name}}\"",
|
||||
"err_403": "$t(fs.rename.err_generic). $t(fs.err_403)",
|
||||
"err_429": "$t(fs.rename.err_generic). $t(fs.err_429)",
|
||||
"err_exists": "$t(fs.rename.err_generic). $t(fs.err_exists)"
|
||||
"err_exists": "$t(fs.rename.err_generic). $t(fs.err_exists)",
|
||||
"err_unsupported": "Unsupported: if you want to rename a directory make sure it is empty"
|
||||
},
|
||||
"upload": {
|
||||
"text": "Upload Files",
|
||||
|
|
|
@ -328,7 +328,8 @@
|
|||
"err_generic": "Errore nello spostamento di file/directory",
|
||||
"err_403": "$t(fs.move.err_generic). $t(fs.err_403)",
|
||||
"err_429": "$t(fs.move.err_generic). $t(fs.err_429)",
|
||||
"err_exists": "$t(fs.move.err_generic). $t(fs.err_exists)"
|
||||
"err_exists": "$t(fs.move.err_generic). $t(fs.err_exists)",
|
||||
"err_unsupported": "Non supportato: se vuoi spostare una directory assicurati che sia vuota"
|
||||
},
|
||||
"rename": {
|
||||
"title": "Rinomina \"{{- name}}\"",
|
||||
|
@ -336,7 +337,8 @@
|
|||
"err_generic": "Impossibile rinominare \"{{- name}}\"",
|
||||
"err_403": "$t(fs.rename.err_generic): $t(fs.err_403)",
|
||||
"err_429": "$t(fs.rename.err_generic): $t(fs.err_429)",
|
||||
"err_exists": "$t(fs.rename.err_generic). $t(fs.err_exists)"
|
||||
"err_exists": "$t(fs.rename.err_generic). $t(fs.err_exists)",
|
||||
"err_unsupported": "Non supportato: se vuoi rinominare una directory assicurati che sia vuota"
|
||||
},
|
||||
"upload": {
|
||||
"text": "Carica file",
|
||||
|
|
|
@ -1428,6 +1428,9 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||
let errorMessage = "";
|
||||
if (error && error.response) {
|
||||
switch (error.response.status) {
|
||||
case 400:
|
||||
errorMessage = "fs.move.err_unsupported";
|
||||
break;
|
||||
case 403:
|
||||
errorMessage = "fs.move.err_403";
|
||||
break;
|
||||
|
@ -1640,6 +1643,9 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
|
|||
let errorMessage;
|
||||
if (error && error.response) {
|
||||
switch (error.response.status) {
|
||||
case 400:
|
||||
errorMessage = "fs.rename.err_unsupported";
|
||||
break;
|
||||
case 403:
|
||||
errorMessage = "fs.rename.err_403";
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue