Skip to content

Commit

Permalink
Get gc id before index blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Nov 21, 2024
1 parent 2f68e9d commit c14b84a
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions fileserver/fileop.go
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,12 @@ func postMultiFiles(rsp http.ResponseWriter, r *http.Request, repoID, parentDir,
cryptKey = key
}

gcID, err := repomgr.GetCurrentGCID(repo.StoreID)
if err != nil {
err := fmt.Errorf("failed to get current gc id for repo %s: %v", repoID, err)
return &appError{err, "", http.StatusInternalServerError}
}

var ids []string
var sizes []int64
if fsm.rstart >= 0 {
Expand Down Expand Up @@ -1714,12 +1720,6 @@ func postMultiFiles(rsp http.ResponseWriter, r *http.Request, repoID, parentDir,
}
}

gcID, err := repomgr.GetCurrentGCID(repo.StoreID)
if err != nil {
err := fmt.Errorf("failed to get current gc id for repo %s: %v", repoID, err)
return &appError{err, "", http.StatusInternalServerError}
}

retStr, err := postFilesAndGenCommit(fileNames, repo.ID, user, canonPath, replace, ids, sizes, lastModify, gcID)
if err != nil {
err := fmt.Errorf("failed to post files and gen commit: %v", err)
Expand Down Expand Up @@ -3160,6 +3160,12 @@ func putFile(rsp http.ResponseWriter, r *http.Request, repoID, parentDir, user,
cryptKey = key
}

gcID, err := repomgr.GetCurrentGCID(repo.StoreID)
if err != nil {
err := fmt.Errorf("failed to get current gc id: %v", err)
return &appError{err, "", http.StatusInternalServerError}
}

var fileID string
var size int64
if fsm.rstart >= 0 {
Expand Down Expand Up @@ -3218,11 +3224,6 @@ func putFile(rsp http.ResponseWriter, r *http.Request, repoID, parentDir, user,
return &appError{err, "", http.StatusInternalServerError}
}

gcID, err := repomgr.GetCurrentGCID(repo.StoreID)
if err != nil {
err := fmt.Errorf("failed to get current gc id: %v", err)
return &appError{err, "", http.StatusInternalServerError}
}
desc := fmt.Sprintf("Modified \"%s\"", fileName)
_, err = genNewCommit(repo, headCommit, rootID, user, desc, true, gcID, true)
if err != nil {
Expand Down Expand Up @@ -3437,6 +3438,12 @@ func commitFileBlocks(repoID, parentDir, fileName, blockIDsJSON, user string, fi
return "", appErr
}

gcID, err := repomgr.GetCurrentGCID(repo.StoreID)
if err != nil {
err := fmt.Errorf("failed to get current gc id: %v", err)
return "", &appError{err, "", http.StatusInternalServerError}
}

fileID, appErr := indexExistedFileBlocks(repoID, repo.Version, blkIDs, fileSize)
if appErr != nil {
return "", appErr
Expand All @@ -3455,11 +3462,6 @@ func commitFileBlocks(repoID, parentDir, fileName, blockIDsJSON, user string, fi
return "", &appError{err, "", http.StatusInternalServerError}
}

gcID, err := repomgr.GetCurrentGCID(repo.StoreID)
if err != nil {
err := fmt.Errorf("failed to get current gc id: %v", err)
return "", &appError{err, "", http.StatusInternalServerError}
}
desc := fmt.Sprintf("Added \"%s\"", fileName)
_, err = genNewCommit(repo, headCommit, rootID, user, desc, true, gcID, true)
if err != nil {
Expand Down

0 comments on commit c14b84a

Please sign in to comment.