"Fossies" - the Fresh Open Source Software Archive

Member "gdrive-2.1.1/drive/revision_delete.go" (28 May 2021, 726 Bytes) of package /linux/misc/old/gdrive-2.1.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 package drive
    2 
    3 import (
    4     "fmt"
    5     "io"
    6 )
    7 
    8 type DeleteRevisionArgs struct {
    9     Out        io.Writer
   10     FileId     string
   11     RevisionId string
   12 }
   13 
   14 func (self *Drive) DeleteRevision(args DeleteRevisionArgs) (err error) {
   15     rev, err := self.service.Revisions.Get(args.FileId, args.RevisionId).Fields("originalFilename").Do()
   16     if err != nil {
   17         return fmt.Errorf("Failed to get revision: %s", err)
   18     }
   19 
   20     if rev.OriginalFilename == "" {
   21         return fmt.Errorf("Deleting revisions for this file type is not supported")
   22     }
   23 
   24     err = self.service.Revisions.Delete(args.FileId, args.RevisionId).Do()
   25     if err != nil {
   26         return fmt.Errorf("Failed to delete revision", err)
   27     }
   28 
   29     fmt.Fprintf(args.Out, "Deleted revision '%s'\n", args.RevisionId)
   30     return
   31 }