Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create abspath dir in case that contents is empty #2164

Merged
merged 4 commits into from
Oct 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/yurthub/storage/disk/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@

// 2. create new file with contents
// TODO: if error happens, we may need retry mechanism, or add some mechanism to do consistency check.
// create abspath dir in case that contents is empty
if err := ds.fsOperator.CreateDir(absPath); err != nil {
rambohe-ch marked this conversation as resolved.
Show resolved Hide resolved
klog.Errorf("could not create dir at %s, %v", absPath, err)
return err

Check warning on line 389 in pkg/yurthub/storage/disk/storage.go

View check run for this annotation

Codecov / codecov/patch

pkg/yurthub/storage/disk/storage.go#L388-L389

Added lines #L388 - L389 were not covered by tests
}
rambohe-ch marked this conversation as resolved.
Show resolved Hide resolved
for key, data := range contents {
path := filepath.Join(ds.baseDir, key.Key())
if err := ds.fsOperator.CreateDir(filepath.Dir(path)); err != nil && err != fs.ErrExists {
Expand Down
Loading