Skip to content

Commit a9c2a65

Browse files
authored
cleanup of hashed directories (#229)
* cleanup of hashed directories Signed-off-by: Ashima-Ashima1 <[email protected]> * publish test version Signed-off-by: Ashima-Ashima1 <[email protected]> * publish test version Signed-off-by: Ashima-Ashima1 <[email protected]> * publish test version Signed-off-by: Ashima-Ashima1 <[email protected]> * publish test version Signed-off-by: Ashima-Ashima1 <[email protected]> * revert chnages Signed-off-by: Ashima-Ashima1 <[email protected]> --------- Signed-off-by: Ashima-Ashima1 <[email protected]>
1 parent a794d8d commit a9c2a65

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2025-07-01T12:50:32Z",
6+
"generated_at": "2025-07-03T08:26:08Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

pkg/mounter/mounter-rclone.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,22 +350,21 @@ func removeRcloneConfigFile(configPath, target string) {
350350
_, err := os.Stat(configPathWithVolID)
351351
if err != nil {
352352
if os.IsNotExist(err) {
353-
klog.Infof("removeRcloneConfigFile: Password file directory does not exist: %s", configPathWithVolID)
353+
klog.Infof("removeRcloneConfigFile: Config file directory does not exist: %s", configPathWithVolID)
354354
return
355355
}
356356
klog.Errorf("removeRcloneConfigFile: Attempt %d - Failed to stat path %s: %v", retry, configPathWithVolID, err)
357357
time.Sleep(constants.Interval)
358358
continue
359359
}
360-
configFile := path.Join(configPathWithVolID, configFileName)
361-
err = os.Remove(configFile)
360+
err = RemoveAll(configPathWithVolID)
362361
if err != nil {
363-
klog.Errorf("removeRcloneConfigFile: Attempt %d - Failed to remove password file %s: %v", retry, configFile, err)
362+
klog.Errorf("removeRcloneConfigFile: Attempt %d - Failed to remove config file path %s: %v", retry, configPathWithVolID, err)
364363
time.Sleep(constants.Interval)
365364
continue
366365
}
367-
klog.Infof("removeRcloneConfigFile: Successfully removed config file: %s", configFile)
366+
klog.Infof("removeRcloneConfigFile: Successfully removed config file path: %s", configPathWithVolID)
368367
return
369368
}
370-
klog.Errorf("removeRcloneConfigFile: Failed to remove config file after %d attempts", maxRetries)
369+
klog.Errorf("removeRcloneConfigFile: Failed to remove config file path after %d attempts", maxRetries)
371370
}

pkg/mounter/mounter-s3fs.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,14 +350,13 @@ func removeS3FSCredFile(credDir, target string) {
350350
time.Sleep(constants.Interval)
351351
continue
352352
}
353-
passwdFile := path.Join(metaPath, passFile)
354-
err = Remove(passwdFile)
353+
err = RemoveAll(metaPath)
355354
if err != nil {
356-
klog.Errorf("removeS3FSCredFile: Attempt %d - Failed to remove password file %s: %v", retry, passwdFile, err)
355+
klog.Errorf("removeS3FSCredFile: Attempt %d - Failed to remove password file path %s: %v", retry, metaPath, err)
357356
time.Sleep(constants.Interval)
358357
continue
359358
}
360-
klog.Infof("removeS3FSCredFile: Successfully removed password file: %s", passwdFile)
359+
klog.Infof("removeS3FSCredFile: Successfully removed password file path: %s", metaPath)
361360
return
362361
}
363362
klog.Errorf("removeS3FSCredFile: Failed to remove password file after %d attempts", maxRetries)

pkg/mounter/mounter-s3fs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func TestRemoveS3FSCredFile_Negative(t *testing.T) {
275275
Stat = func(path string) (os.FileInfo, error) {
276276
return nil, nil
277277
}
278-
Remove = func(path string) error {
278+
RemoveAll = func(path string) error {
279279
called++
280280
return errors.New("remove failed")
281281
}

pkg/mounter/mounter.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var (
2727
Chmod = os.Chmod
2828
Stat = os.Stat
2929
Remove = os.Remove
30+
RemoveAll = os.RemoveAll
3031
)
3132

3233
type Mounter interface {

0 commit comments

Comments
 (0)