mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-05-11 17:49:42 +08:00
feat: rename file only when storagePath exists
This commit is contained in:
@@ -5,4 +5,5 @@ import "errors"
|
||||
var (
|
||||
ErrFailedToCreateDirectory = errors.New("webdav: failed to create directory")
|
||||
ErrFailedToWriteFile = errors.New("webdav: failed to write file")
|
||||
ErrFailedToCheckFileExists = errors.New("webdav: failed to check if file exists")
|
||||
)
|
||||
|
||||
@@ -57,3 +57,13 @@ func (w *Webdav) Save(ctx context.Context, r io.Reader, storagePath string) erro
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *Webdav) Exists(ctx context.Context, storagePath string) bool {
|
||||
common.Log.Debugf("Checking if file exists at %s", storagePath)
|
||||
exists, err := w.client.Exists(ctx, storagePath)
|
||||
if err != nil {
|
||||
common.Log.Errorf("Failed to check if file exists at %s: %v", storagePath, err)
|
||||
return false
|
||||
}
|
||||
return exists
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user