drive: don't delete files with multiple parents to avoid data loss

Rclone can't safely delete files with multiple parents without
PATCHing the parents list. This can be done, but since multiple
parents are going away to be replaced by drive shortcuts we return an
error for now.

See #4013
vfs-used-is-size
Nick Craig-Wood 2020-03-31 17:25:15 +01:00
parent 5fa6a28f70
commit ff0a299bfb
1 changed files with 5 additions and 0 deletions

View File

@ -551,6 +551,7 @@ type baseObject struct {
modifiedDate string // RFC3339 time it was last modified
mimeType string // The object MIME type
bytes int64 // size of the object
parents int // number of parents
}
type documentObject struct {
baseObject
@ -1176,6 +1177,7 @@ func (f *Fs) newBaseObject(remote string, info *drive.File) baseObject {
modifiedDate: modifiedDate,
mimeType: info.MimeType,
bytes: size,
parents: len(info.Parents),
}
}
@ -2989,6 +2991,9 @@ func (o *linkObject) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo
// Remove an object
func (o *baseObject) Remove(ctx context.Context) error {
if o.parents > 1 {
return errors.New("can't delete safely - has multiple parents")
}
var err error
err = o.fs.pacer.Call(func() (bool, error) {
if o.fs.opt.UseTrash {