Skip to content

Fix data loss in rmtree when deletion fails#45

Open
desmondwong1215 wants to merge 2 commits intogit-mastery:mainfrom
desmondwong1215:fix/rmtree
Open

Fix data loss in rmtree when deletion fails#45
desmondwong1215 wants to merge 2 commits intogit-mastery:mainfrom
desmondwong1215:fix/rmtree

Conversation

@desmondwong1215
Copy link

Fixes NUS-CS2103-AY2526-S2/forum#82

When rmtree() fails (e.g., folder locked by another process), shutil.rmtree partially deletes files before raising an exception. This causes permanent data loss - users lose their progress.json despite the operation failing. It also applies to other parts in the app that use rmtree.

Solution:
Implement backup-and-restore mechanism in rmtree()):

  1. Create a hidden backup before deletion
  2. Attempt deletion
    2a. If deletion fails: restore from backup automatically
    2b. If restoration also fails: preserve the backup and show the user the path; the user can manually update the path before retrying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Gitmastery] Local progress also deleted when running gitmastery progress sync on or off while accessing progress folder from another terminal

1 participant