mirror of
https://github.com/rclone/rclone
synced 2025-01-10 13:06:26 +01:00
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
This commit is contained in:
parent
5fa6a28f70
commit
ff0a299bfb
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user