diff options
author | zeripath <art27@cantab.net> | 2020-03-09 19:56:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 19:56:18 +0000 |
commit | 9269b7f6271e865f2eeda7a68ed8f1afe7431bad (patch) | |
tree | 9b42ddac5ee366a08b9450848b8c40e40846b9b5 /modules/lfs/content_store.go | |
parent | 3fc4f3670cb748e02d786111d2029ef1e23a9640 (diff) | |
download | gitea-9269b7f6271e865f2eeda7a68ed8f1afe7431bad.tar.gz gitea-9269b7f6271e865f2eeda7a68ed8f1afe7431bad.zip |
Multiple LFS improvements (#10667)
* Add more logging in the LFS server
Adds more logging in the LFS server and stops sending internal server
error information to the client
* Add LFS Lock cursor implementation
* Simplify Claims in LFS and remove the float64 casts
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'modules/lfs/content_store.go')
-rw-r--r-- | modules/lfs/content_store.go | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/modules/lfs/content_store.go b/modules/lfs/content_store.go index 895b51b8ba..36e84a31ba 100644 --- a/modules/lfs/content_store.go +++ b/modules/lfs/content_store.go @@ -9,6 +9,7 @@ import ( "path/filepath" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/log" ) var ( @@ -28,10 +29,14 @@ func (s *ContentStore) Get(meta *models.LFSMetaObject, fromByte int64) (io.ReadC f, err := os.Open(path) if err != nil { + log.Error("Whilst trying to read LFS OID[%s]: Unable to open %s Error: %v", meta.Oid, path, err) return nil, err } if fromByte > 0 { _, err = f.Seek(fromByte, os.SEEK_CUR) + if err != nil { + log.Error("Whilst trying to read LFS OID[%s]: Unable to seek to %d Error: %v", meta.Oid, fromByte, err) + } } return f, err } @@ -43,11 +48,13 @@ func (s *ContentStore) Put(meta *models.LFSMetaObject, r io.Reader) error { dir := filepath.Dir(path) if err := os.MkdirAll(dir, 0750); err != nil { + log.Error("Whilst putting LFS OID[%s]: Unable to create the LFS directory: %s Error: %v", meta.Oid, dir, err) return err } file, err := os.OpenFile(tmpPath, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0640) if err != nil { + log.Error("Whilst putting LFS OID[%s]: Unable to open temporary file for writing: %s Error: %v", tmpPath, err) return err } defer os.Remove(tmpPath) @@ -57,6 +64,7 @@ func (s *ContentStore) Put(meta *models.LFSMetaObject, r io.Reader) error { written, err := io.Copy(hw, r) if err != nil { + log.Error("Whilst putting LFS OID[%s]: Failed to copy to tmpPath: %s Error: %v", meta.Oid, tmpPath, err) file.Close() return err } @@ -71,7 +79,12 @@ func (s *ContentStore) Put(meta *models.LFSMetaObject, r io.Reader) error { return errHashMismatch } - return os.Rename(tmpPath, path) + if err := os.Rename(tmpPath, path); err != nil { + log.Error("Whilst putting LFS OID[%s]: Unable to move tmp file to final destination: %s Error: %v", meta.Oid, path, err) + return err + } + + return nil } // Exists returns true if the object exists in the content store. @@ -91,6 +104,7 @@ func (s *ContentStore) Verify(meta *models.LFSMetaObject) (bool, error) { if os.IsNotExist(err) || err == nil && fi.Size() != meta.Size { return false, nil } else if err != nil { + log.Error("Unable stat file: %s for LFS OID[%s] Error: %v", path, meta.Oid, err) return false, err } |