From c6e6c8ee7e86b774436a18e72bb3b5f1c495ae43 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Fri, 17 Nov 2023 15:21:57 -0800 Subject: [PATCH] fix cross device rename --- server/routes.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/routes.go b/server/routes.go index 58145576..6c1386b0 100644 --- a/server/routes.go +++ b/server/routes.go @@ -666,8 +666,14 @@ func HeadBlobHandler(c *gin.Context) { } func CreateBlobHandler(c *gin.Context) { + targetPath, err := GetBlobsPath(c.Param("digest")) + if err != nil { + c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) + return + } + hash := sha256.New() - temp, err := os.CreateTemp("", c.Param("digest")) + temp, err := os.CreateTemp(filepath.Dir(targetPath), c.Param("digest")) if err != nil { c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return @@ -690,12 +696,6 @@ func CreateBlobHandler(c *gin.Context) { return } - targetPath, err := GetBlobsPath(c.Param("digest")) - if err != nil { - c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) - return - } - if err := os.Rename(temp.Name(), targetPath); err != nil { c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return