Browse Source

fsck: add fixer that fully removes a stream

tags/nilmdb-2.2.0
Jim Paris 2 years ago
parent
commit
905e325ded
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      nilmdb/fsck/fsck.py

+ 18
- 0
nilmdb/fsck/fsck.py View File

@@ -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):


Loading…
Cancel
Save