Skip to content

Commit a6192d9

Browse files
committed
fix: Avoid error when files are changed during tar
Assisted-by: ClaudeCode:claude-fable-5 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
1 parent 7982162 commit a6192d9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lib/commands/state.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ export function saveState(): Cypress.Chainable<string> {
1212
const snapshot = Math.random().toString(36).substring(7)
1313

1414
runCommand(`rm /var/www/html/data-${snapshot}.tar`, { failOnNonZeroExit: false })
15-
runCommand(`tar cf /var/www/html/data-${snapshot}.tar ./data`)
15+
// The instance keeps writing into ./data while we archive it (e.g. the
16+
// nextcloud.log, caches, session files), so a file can change mid-read and
17+
// GNU tar exits 1 with "file changed as we read it". That is harmless for a
18+
// test-state snapshot: silence the warning and treat exit 1 (benign,
19+
// "some files differ") as success while still failing on a real error
20+
// (exit 2, fatal).
21+
runCommand(`tar --warning=no-file-changed -cf /var/www/html/data-${snapshot}.tar ./data || [ $? -eq 1 ]`)
1622

1723
cy.log(`Created snapshot ${snapshot}`)
1824

0 commit comments

Comments
 (0)