Skip to content

Commit 3a6c786

Browse files
authored
feat: use parent folder (#72)
1 parent 6f6b4b7 commit 3a6c786

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/mod/task/handler.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func (c *CustomTaskHandler) handleUploadTask(task *openDpsV1alpha1Resource.Task)
233233
continue
234234
}
235235

236+
parentFolder := filepath.Dir(folder)
236237
filePaths, err := utils.GetAllFilePaths(folder, &utils.SymWalkOptions{
237238
FollowSymlinks: true,
238239
SkipPermissionErrors: true,
@@ -259,7 +260,7 @@ func (c *CustomTaskHandler) handleUploadTask(task *openDpsV1alpha1Resource.Task)
259260
log.Infof("file %s, mod time: %s", path, info.ModTime().String())
260261
//nolint: nestif // check file modification time
261262
if info.ModTime().After(startTime.AsTime()) && info.ModTime().Before(endTime.AsTime()) {
262-
filename, err := filepath.Rel(folder, path)
263+
filename, err := filepath.Rel(parentFolder, path)
263264
if err != nil {
264265
log.Errorf("Failed to get relative path: %v", err)
265266
filename = filepath.Base(path)
@@ -281,7 +282,7 @@ func (c *CustomTaskHandler) handleUploadTask(task *openDpsV1alpha1Resource.Task)
281282
log.Infof("File %s has birth time: %s", path, stat.BirthTime().String())
282283

283284
if stat.BirthTime().After(startTime.AsTime()) && stat.BirthTime().Before(endTime.AsTime()) {
284-
filename, err := filepath.Rel(folder, path)
285+
filename, err := filepath.Rel(parentFolder, path)
285286
if err != nil {
286287
log.Errorf("Failed to get relative path: %v", err)
287288
filename = filepath.Base(path)
@@ -321,6 +322,7 @@ func (c *CustomTaskHandler) handleUploadTask(task *openDpsV1alpha1Resource.Task)
321322
continue
322323
}
323324

325+
parentFolder := filepath.Dir(file)
324326
filePaths, err := utils.GetAllFilePaths(file, &utils.SymWalkOptions{
325327
FollowSymlinks: true,
326328
SkipPermissionErrors: true,
@@ -344,7 +346,7 @@ func (c *CustomTaskHandler) handleUploadTask(task *openDpsV1alpha1Resource.Task)
344346
continue
345347
}
346348

347-
filename, err := filepath.Rel(file, path)
349+
filename, err := filepath.Rel(parentFolder, path)
348350
if err != nil {
349351
log.Errorf("Failed to get relative path: %v", err)
350352
filename = filepath.Base(path)

0 commit comments

Comments
 (0)