Skip to content

Commit c7948ce

Browse files
authored
Merge pull request #20 from InfuseAI/bug/cross-device-rename
Fit art get in non-root device would fail
2 parents 963be14 + e540012 commit c7948ce

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

internal/core/manager.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ func (mngr *ArtifactManager) UploadBlob(localPath, hash string, checkSkip bool)
8686
return BlobUploadResult{Skip: false}, err
8787
}
8888

89-
func (mngr *ArtifactManager) Download(repoPath, localPath string, meter *meter.Meter) error {
89+
func (mngr *ArtifactManager) Download(repoPath, localPath, tmpDir string, meter *meter.Meter) error {
9090
// Copy from repo to tmp
91-
tmpDir := path.Join(mngr.metadataDir, "tmp")
9291
err := os.MkdirAll(tmpDir, fs.ModePerm)
9392
if err != nil {
9493
return err
@@ -135,7 +134,9 @@ func (mngr *ArtifactManager) DownloadBlob(localPath, hash string) (BlobDownloadR
135134
}
136135

137136
repoPath := MakeObjectPath(hash)
138-
err = mngr.Download(repoPath, blobPath, mngr.meter)
137+
tmpDir := path.Join(mngr.baseDir, ".art", "tmp")
138+
139+
err = mngr.Download(repoPath, blobPath, tmpDir, mngr.meter)
139140
if err != nil {
140141
return BlobDownloadResult{}, err
141142
}
@@ -201,7 +202,8 @@ func (mngr *ArtifactManager) GetRef(ref string) (string, error) {
201202
return "", err
202203
}
203204

204-
err = mngr.Download(refPath, localPath, nil)
205+
tmpDir := path.Join(mngr.metadataDir, ".art", "tmp")
206+
err = mngr.Download(refPath, localPath, tmpDir, nil)
205207
if err != nil {
206208
return "", err
207209
}
@@ -230,7 +232,8 @@ func (mngr *ArtifactManager) GetCommit(hash string) (*Commit, error) {
230232
return nil, err
231233
}
232234

233-
err = mngr.Download(commitPath, localPath, nil)
235+
tmpDir := path.Join(mngr.metadataDir, ".art", "tmp")
236+
err = mngr.Download(commitPath, localPath, tmpDir, nil)
234237
if err != nil {
235238
return nil, err
236239
}
@@ -672,6 +675,10 @@ func (mngr *ArtifactManager) Pull(options PullOptions) error {
672675
return err
673676
}
674677
}
678+
_, err = removeEmptyDirs(filepath.Join(mngr.baseDir, ".art"), true)
679+
if err != nil {
680+
return err
681+
}
675682

676683
fmt.Println()
677684
result.Print(false)

0 commit comments

Comments
 (0)