aboutsummaryrefslogtreecommitdiffstats
path: root/services/pull
diff options
context:
space:
mode:
Diffstat (limited to 'services/pull')
-rw-r--r--services/pull/lfs.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/services/pull/lfs.go b/services/pull/lfs.go
index a1981b8253..b902c63619 100644
--- a/services/pull/lfs.go
+++ b/services/pull/lfs.go
@@ -70,6 +70,8 @@ func createLFSMetaObjectsFromCatFileBatch(catFileBatchReader *io.PipeReader, wg
defer wg.Done()
defer catFileBatchReader.Close()
+ contentStore := lfs.NewContentStore()
+
bufferedReader := bufio.NewReader(catFileBatchReader)
buf := make([]byte, 1025)
for {
@@ -101,10 +103,16 @@ func createLFSMetaObjectsFromCatFileBatch(catFileBatchReader *io.PipeReader, wg
}
pointerBuf = pointerBuf[:size]
// Now we need to check if the pointerBuf is an LFS pointer
- pointer := lfs.IsPointerFile(&pointerBuf)
- if pointer == nil {
+ pointer, _ := lfs.ReadPointerFromBuffer(pointerBuf)
+ if !pointer.IsValid() {
continue
}
+
+ exist, _ := contentStore.Exists(pointer)
+ if !exist {
+ continue
+ }
+
// Then we need to check that this pointer is in the db
if _, err := pr.HeadRepo.GetLFSMetaObjectByOid(pointer.Oid); err != nil {
if err == models.ErrLFSObjectNotExist {
@@ -117,8 +125,9 @@ func createLFSMetaObjectsFromCatFileBatch(catFileBatchReader *io.PipeReader, wg
// OK we have a pointer that is associated with the head repo
// and is actually a file in the LFS
// Therefore it should be associated with the base repo
- pointer.RepositoryID = pr.BaseRepoID
- if _, err := models.NewLFSMetaObject(pointer); err != nil {
+ meta := &models.LFSMetaObject{Pointer: pointer}
+ meta.RepositoryID = pr.BaseRepoID
+ if _, err := models.NewLFSMetaObject(meta); err != nil {
_ = catFileBatchReader.CloseWithError(err)
break
}