working commit
This commit is contained in:
+32
-1
@@ -205,7 +205,6 @@ func (store *Storage) WriteUpload(uploadID string, source io.Reader) (int64, str
|
||||
func (store *Storage) LinkUpload(reference, digest string) error {
|
||||
var err error
|
||||
uploadPath := store.makeUppath(reference)
|
||||
blobPath := store.makeBlobpath(digest)
|
||||
|
||||
blobdir := store.makeBlobsubdir()
|
||||
_, err = os.Stat(blobdir)
|
||||
@@ -218,6 +217,20 @@ func (store *Storage) LinkUpload(reference, digest string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
blobPath := store.makeBlobpath(digest)
|
||||
_, err = os.Stat(blobPath)
|
||||
if err == nil {
|
||||
err = os.Remove(blobPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
err = nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.Link(uploadPath, blobPath)
|
||||
if err != nil {
|
||||
@@ -240,6 +253,24 @@ func (store *Storage) RemoveUpload(digest string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (st *Storage) UploadExists(name, reference string) (bool, int64, error) {
|
||||
var err error
|
||||
var fileSize int64
|
||||
|
||||
uploadPath := st.makeUppath(reference)
|
||||
|
||||
fileStat, err := os.Stat(uploadPath)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return false, 0, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, 0, err
|
||||
}
|
||||
|
||||
fileSize = fileStat.Size()
|
||||
return true, fileSize, err
|
||||
}
|
||||
|
||||
func (store *Storage) WriteBlob(digest string, source io.Reader) (int64, string, error) {
|
||||
var err error
|
||||
var recsize int64
|
||||
|
||||
Reference in New Issue
Block a user