|
|
@@ -328,6 +328,24 @@ class Fsck(object): |
|
|
|
f.truncate(newsize) |
|
|
|
raise RetryFsck |
|
|
|
|
|
|
|
def fix_remove_stream(self, sid, path, bulk, reason): |
|
|
|
msg = f"stream {path} is corrupted: {reason}" |
|
|
|
if not self.fix: |
|
|
|
raise FixableFsckError(msg) |
|
|
|
# Remove the stream from disk and the database |
|
|
|
err(f"\n{msg}\n") |
|
|
|
err(f"Removing stream {path} from disk and database\n") |
|
|
|
shutil.rmtree(bulk) |
|
|
|
with self.sql: |
|
|
|
cur = self.sql.cursor() |
|
|
|
cur.execute("DELETE FROM streams WHERE id=?", |
|
|
|
(sid,)) |
|
|
|
if cur.rowcount != 1: # pragma: no cover (shouldn't fail) |
|
|
|
raise FsckError("failed to remove stream") |
|
|
|
cur.execute("DELETE FROM ranges WHERE stream_id=?", (sid,)) |
|
|
|
cur.execute("DELETE FROM metadata WHERE stream_id=?", (sid,)) |
|
|
|
raise RetryFsck |
|
|
|
|
|
|
|
### Check interval endpoints |
|
|
|
|
|
|
|
def check_intervals(self): |
|
|
|