diff options
| -rw-r--r-- | drive/sync.go | 10 | ||||
| -rw-r--r-- | drive/upload.go | 12 | 
2 files changed, 22 insertions, 0 deletions
| diff --git a/drive/sync.go b/drive/sync.go index 204e7c2..2124f8f 100644 --- a/drive/sync.go +++ b/drive/sync.go @@ -73,6 +73,16 @@ func (self *Drive) prepareSyncFiles(localPath string, root *drive.File, cmp File      }, nil  } +func (self *Drive) isSyncFile(id string) (bool, error) { +    f, err := self.service.Files.Get(id).Fields("appProperties").Do() +    if err != nil { +        return false, fmt.Errorf("Failed to get file: %s", err) +    } + +    _, ok := f.AppProperties["sync"] +    return ok, nil +} +  func prepareLocalFiles(root string) ([]*LocalFile, error) {      var files []*LocalFile diff --git a/drive/upload.go b/drive/upload.go index 2b8c7c3..0bbc014 100644 --- a/drive/upload.go +++ b/drive/upload.go @@ -29,6 +29,18 @@ func (self *Drive) Upload(args UploadArgs) error {          return fmt.Errorf("Chunk size is to big, max chunk size for this computer is %d", intMax() - 1)      } +    // Ensure that none of the parents are sync dirs +    for _, parent := range args.Parents { +        isSyncDir, err := self.isSyncFile(parent) +        if err != nil { +            return err +        } + +        if isSyncDir { +            return fmt.Errorf("%s is a sync directory, use 'sync upload' instead", parent) +        } +    } +      if args.Recursive {          return self.uploadRecursive(args)      } | 
