indicate readonly mode

This commit is contained in:
Christian Zangl 2020-01-22 18:09:17 +01:00
parent 9366259daa
commit 5426995fa8
3 changed files with 11 additions and 9 deletions

View File

@ -8,7 +8,7 @@ chkbit is independent of the file system and can help you detect bitrot on you p
0 bits flipped | 1 bit flipped | 2 bits flipped | 3 bits flipped 0 bits flipped | 1 bit flipped | 2 bits flipped | 3 bits flipped
-------------- | -------------- | -------------- | -------------- -------------- | -------------- | -------------- | --------------
![](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Bitrot_in_JPEG_files%2C_0_bits_flipped.jpg/180px-Bitrot_in_JPEG_files%2C_0_bits_flipped.jpg) | ![](https://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Bitrot_in_JPEG_files%2C_1_bit_flipped.jpg/180px-Bitrot_in_JPEG_files%2C_1_bit_flipped.jpg) | ![](https://upload.wikimedia.org/wikipedia/commons/thumb/3/37/Bitrot_in_JPEG_files%2C_2_bits_flipped.jpg/180px-Bitrot_in_JPEG_files%2C_2_bits_flipped.jpg) | ![](https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Bitrot_in_JPEG_files%2C_3_bits_flipped.jpg/180px-Bitrot_in_JPEG_files%2C_3_bits_flipped.jpg) | ![](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2f/Bitrot_in_JPEG_files%2C_0_bits_flipped.jpg/180px-Bitrot_in_JPEG_files%2C_0_bits_flipped.jpg) | ![](https://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Bitrot_in_JPEG_files%2C_1_bit_flipped.jpg/180px-Bitrot_in_JPEG_files%2C_1_bit_flipped.jpg) | ![](https://upload.wikimedia.org/wikipedia/commons/thumb/3/37/Bitrot_in_JPEG_files%2C_2_bits_flipped.jpg/180px-Bitrot_in_JPEG_files%2C_2_bits_flipped.jpg) | ![](https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Bitrot_in_JPEG_files%2C_3_bits_flipped.jpg/180px-Bitrot_in_JPEG_files%2C_3_bits_flipped.jpg) |
Data degradation (aka bitrot) is the gradual corruption of computer data due to an accumulation of non-critical failures in a data storage device. It results from the gradual decay of storage media over the course of years or longer. Causes vary by medium. Data degradation (aka bitrot) is the gradual corruption of computer data due to an accumulation of non-critical failures in a data storage device. It results from the gradual decay of storage media over the course of years or longer. Causes vary by medium.
@ -59,7 +59,7 @@ Status codes:
ROT: error, bitrot detected ROT: error, bitrot detected
EIX: error, index damaged EIX: error, index damaged
old: warning, file replaced by an older version old: warning, file replaced by an older version
add: add to index new: new file
upd: file updated upd: file updated
ok : check ok ok : check ok
skp: skipped (see .chkbitignore) skp: skipped (see .chkbitignore)

View File

@ -6,7 +6,7 @@ import json
from enum import Enum from enum import Enum
from chkbit import hashfile, hashtext from chkbit import hashfile, hashtext
VERSION = 2 # index version VERSION = 2 # index version
INDEX = ".chkbit" INDEX = ".chkbit"
IGNORE = ".chkbitignore" IGNORE = ".chkbitignore"
@ -15,7 +15,7 @@ class Stat(Enum):
ERR_BITROT = "ROT" ERR_BITROT = "ROT"
ERR_IDX = "EIX" ERR_IDX = "EIX"
WARN_OLD = "old" WARN_OLD = "old"
ADD = "add" NEW = "new"
UPDATE = "upd" UPDATE = "upd"
OK = "ok " OK = "ok "
SKIP = "skp" SKIP = "skp"
@ -46,7 +46,7 @@ class Index:
def should_ignore(self, name): def should_ignore(self, name):
for ignore in self.ignore: for ignore in self.ignore:
if fnmatch.fnmatch(name, ignore): if fnmatch.fnmatch(name, ignore):
return True return True
return False return False
def _setmod(self): def _setmod(self):
@ -66,7 +66,7 @@ class Index:
def check_fix(self, force): def check_fix(self, force):
for name in self.new.keys(): for name in self.new.keys():
if not name in self.old: if not name in self.old:
self._log(Stat.ADD, name) self._log(Stat.NEW, name)
self._setmod() self._setmod()
continue continue

View File

@ -11,7 +11,7 @@ Status codes:
ROT: error, bitrot detected ROT: error, bitrot detected
EIX: error, index damaged EIX: error, index damaged
old: warning, file replaced by an older version old: warning, file replaced by an older version
add: add to index new: new file
upd: file updated upd: file updated
ok : check ok ok : check ok
skp: skipped (see .chkbitignore) skp: skipped (see .chkbitignore)
@ -35,7 +35,7 @@ class Main:
else: else:
if stat in [Stat.ERR_BITROT, Stat.INTERNALEXCEPTION]: if stat in [Stat.ERR_BITROT, Stat.INTERNALEXCEPTION]:
self.err_list.append(path) self.err_list.append(path)
if stat in [Stat.OK, Stat.UPDATE, Stat.ADD]: if stat in [Stat.OK, Stat.UPDATE, Stat.NEW]:
self.total += 1 self.total += 1
if self.verbose or not stat in [Stat.OK, Stat.SKIP]: if self.verbose or not stat in [Stat.OK, Stat.SKIP]:
print(stat.value, path) print(stat.value, path)
@ -101,7 +101,9 @@ class Main:
def print_result(self): def print_result(self):
if not self.quiet: if not self.quiet:
print(f"Processed {self.total} file(s).") print(
f"Processed {self.total} file(s){' in readonly mode' if not self.args.update else ''}."
)
if self.modified: if self.modified:
print("Indices were updated.") print("Indices were updated.")