Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bluezip.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
import time
import sys
import stat
import re
import os

Expand Down Expand Up @@ -148,6 +149,11 @@ def rollback(db, session):
db.execute('UPDATE session SET rollback = ? WHERE id = ?', (session, prev_session))
db.commit()

def remove_readonly(func, path, _):
"Clear the readonly bit and reattempt the removal"
os.chmod(path, stat.S_IWRITE)
func(path)

class Bluezip:
def __init__(self, db, settings, session, args):
self.db = db
Expand Down Expand Up @@ -217,7 +223,7 @@ def process_game(self, game):
pcolor('red', f'Error: {e} when storing {game.title}. Skipped.')
return
self.db.commit()
shutil.rmtree(tmp)
shutil.rmtree(tmp, onerror=remove_readonly)
if revision == 1:
self.cleanup_obsolete(game, sha256)

Expand Down