onedrive: allow setting permissions to fail if failok flag is set
For example using --onedrive-metadata-permissions read,write,failok Will allow permissions to be read and written but if the writing fails, then only an ERROR will be written in the log and the transfer won't fail.
This commit is contained in:
parent
91192c2c5e
commit
7b89735ae7
1 changed files with 14 additions and 0 deletions
|
@ -133,6 +133,7 @@ func (rwChoices) Choices() []fs.BitsChoicesInfo {
|
|||
{Bit: uint64(rwOff), Name: "off"},
|
||||
{Bit: uint64(rwRead), Name: "read"},
|
||||
{Bit: uint64(rwWrite), Name: "write"},
|
||||
{Bit: uint64(rwFailOK), Name: "failok"},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,6 +143,7 @@ type rwChoice = fs.Bits[rwChoices]
|
|||
const (
|
||||
rwRead rwChoice = 1 << iota
|
||||
rwWrite
|
||||
rwFailOK
|
||||
rwOff rwChoice = 0
|
||||
)
|
||||
|
||||
|
@ -158,6 +160,9 @@ var rwExamples = fs.OptionExamples{{
|
|||
}, {
|
||||
Value: (rwRead | rwWrite).String(),
|
||||
Help: "Read and Write the value.",
|
||||
}, {
|
||||
Value: rwFailOK.String(),
|
||||
Help: "If writing fails log errors only, don't fail the transfer",
|
||||
}}
|
||||
|
||||
// Metadata describes metadata properties shared by both Objects and Directories
|
||||
|
@ -363,6 +368,15 @@ func (m *Metadata) WritePermissions(ctx context.Context) (err error) {
|
|||
if m.normalizedID == "" {
|
||||
return errors.New("internal error: normalizedID is missing")
|
||||
}
|
||||
if m.fs.opt.MetadataPermissions.IsSet(rwFailOK) {
|
||||
// If failok is set, allow the permissions setting to fail and only log an ERROR
|
||||
defer func() {
|
||||
if err != nil {
|
||||
fs.Errorf(m.fs, "Ignoring error as failok is set: %v", err)
|
||||
err = nil
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// compare current to queued and sort into add/update/remove queues
|
||||
add, update, remove := m.sortPermissions()
|
||||
|
|
Loading…
Reference in a new issue