[MM-60888] Fix: Retention can cause unrelated files to be deleted (#29897)

* fix for deleting non-bulk export files and directories

* add job worker setup and running to helper_test.go

* add infrastructure for e2e testing of workers; test ExportDelete

* linting

* use retention days in test instead of magic number
Этот коммит содержится в:
Christopher Poile
2025-01-22 15:15:33 -05:00
коммит произвёл GitHub
родитель 4ed702ccff
Коммит e8eb279874
3 изменённых файлов: 168 добавлений и 3 удалений

Просмотреть файл

@@ -5,6 +5,7 @@ package export_delete
import (
"path/filepath"
"strings"
"time"
"github.com/wiggin77/merror"
@@ -41,6 +42,12 @@ func MakeWorker(jobServer *jobs.JobServer, app AppIface) *jobs.SimpleWorker {
errors := merror.New()
for i := range exports {
filename := filepath.Base(exports[i])
// Ignore files that were not created by the bulk export command
if !strings.HasSuffix(filename, "_export.zip") {
continue
}
modTime, appErr := app.ExportFileModTime(filepath.Join(exportPath, filename))
if appErr != nil {
logger.Debug("Worker: Failed to get file modification time",