diff options
| author | Petter Rasmussen | 2016-02-02 22:57:48 +0100 |
|---|---|---|
| committer | Petter Rasmussen | 2016-02-02 23:00:18 +0100 |
| commit | 4c317d16b6152bdd7972f91bf7ccb9ead8900c09 (patch) | |
| tree | 47206d1de64d975364297d61f1ce228a9e89eef7 | |
| parent | bc29d65240130c5908a843c97672b79c2495678c (diff) | |
| download | gdrive-4c317d16b6152bdd7972f91bf7ccb9ead8900c09.tar.bz2 | |
Close files
| -rw-r--r-- | drive/upload.go | 6 | ||||
| -rw-r--r-- | drive/upload_sync.go | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/drive/upload.go b/drive/upload.go index 1e145f7..3a1a34c 100644 --- a/drive/upload.go +++ b/drive/upload.go @@ -59,6 +59,9 @@ func (self *Drive) uploadDirectory(args UploadArgs) error { return err } + // Close file on function exit + defer srcFile.Close() + // Make directory on drive f, err := self.mkdir(MkdirArgs{ Out: args.Out, @@ -98,6 +101,9 @@ func (self *Drive) uploadFile(args UploadArgs) (*drive.File, error) { return nil, err } + // Close file on function exit + defer srcFile.Close() + // Instantiate empty drive file dstFile := &drive.File{} diff --git a/drive/upload_sync.go b/drive/upload_sync.go index a2a0640..66e1456 100644 --- a/drive/upload_sync.go +++ b/drive/upload_sync.go @@ -227,6 +227,9 @@ func (self *Drive) uploadMissingFile(parentId string, lf *localFile, args Upload return fmt.Errorf("Failed to open file: %s", err) } + // Close file on function exit + defer srcFile.Close() + // Instantiate drive file dstFile := &drive.File{ Name: lf.info.Name(), @@ -254,6 +257,9 @@ func (self *Drive) updateChangedFile(cf *changedFile, args UploadSyncArgs) error return fmt.Errorf("Failed to open file: %s", err) } + // Close file on function exit + defer srcFile.Close() + // Instantiate drive file dstFile := &drive.File{} |
