mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
user: add a field to indicate whether the password is set
A structure similar to the one used for secrets would be better, but we don't want to break backwards compatibility. Also document that omitting the password field in the request body will preserve the current password when updating a user using the REST API. Added a test case for this. Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -161,7 +161,13 @@ func (fs *GCSFs) Open(name string, offset int64) (File, *pipeat.PipeReaderAt, fu
|
||||
}
|
||||
|
||||
// Create creates or opens the named file for writing
|
||||
func (fs *GCSFs) Create(name string, flag int) (File, *PipeWriter, func(), error) {
|
||||
func (fs *GCSFs) Create(name string, flag, checks int) (File, *PipeWriter, func(), error) {
|
||||
if checks&CheckParentDir != 0 {
|
||||
_, err := fs.Stat(path.Dir(name))
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
}
|
||||
r, w, err := pipeat.PipeInDir(fs.localTempDir)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
@@ -227,6 +233,10 @@ func (fs *GCSFs) Rename(source, target string) (int, int64, error) {
|
||||
if source == target {
|
||||
return -1, -1, nil
|
||||
}
|
||||
_, err := fs.Stat(path.Dir(target))
|
||||
if err != nil {
|
||||
return -1, -1, err
|
||||
}
|
||||
fi, err := fs.getObjectStat(source)
|
||||
if err != nil {
|
||||
return -1, -1, err
|
||||
@@ -704,7 +714,7 @@ func (fs *GCSFs) resolve(name, prefix, contentType string) (string, bool) {
|
||||
return result, isDir
|
||||
}
|
||||
|
||||
// getObjectStat returns the stat result and the real object name as first value
|
||||
// getObjectStat returns the stat result
|
||||
func (fs *GCSFs) getObjectStat(name string) (os.FileInfo, error) {
|
||||
attrs, err := fs.headObject(name)
|
||||
if err == nil {
|
||||
@@ -823,7 +833,7 @@ func (fs *GCSFs) mkdirInternal(name string) error {
|
||||
if !strings.HasSuffix(name, "/") {
|
||||
name += "/"
|
||||
}
|
||||
_, w, _, err := fs.Create(name, -1)
|
||||
_, w, _, err := fs.Create(name, -1, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user