From: PhiTux Date: Sat, 19 Jul 2025 15:07:30 +0000 (+0200) Subject: minimal speedup of migration X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=4826a9b5bca0b66684301d956c7acf5cf418048b;p=DailyTxT.git minimal speedup of migration --- diff --git a/backend/utils/migration.go b/backend/utils/migration.go index da69b73..7c9b59c 100644 --- a/backend/utils/migration.go +++ b/backend/utils/migration.go @@ -625,6 +625,12 @@ func migrateLogs(oldDir, newDir string, oldKey string, newKey string, progress * processedMonths := 0 + oldKeyBytes, err := base64.URLEncoding.DecodeString(oldKey) + if err != nil { + Logger.Printf("Error decoding oldKey %v", err) + progress.ErrorCount++ + } + // Process all months for _, monthInfo := range allMonthFiles { @@ -679,13 +685,6 @@ func migrateLogs(oldDir, newDir string, oldKey string, newKey string, progress * continue } - oldKeyBytes, err := base64.URLEncoding.DecodeString(oldKey) - if err != nil { - Logger.Printf("Error decoding oldKey %v", err) - progress.ErrorCount++ - continue - } - // Loop through all days and decrypt/encrypt the texts for i, dayInterface := range days { day, ok := dayInterface.(map[string]any) @@ -1070,13 +1069,12 @@ func migrateFiles(oldFilesDir, newDir string, oldKey string, newKey string, prog processedFiles++ - // Update progress occasionally - if i%5 == 0 || i == len(fileRefs)-1 { - progress.ProcessedItems = processedFiles - if progressChan != nil { - progressChan <- *progress - } + // Update progress + progress.ProcessedItems = processedFiles + if progressChan != nil { + progressChan <- *progress } + } // Third pass: update all month files with new file IDs