From 47ca2eae0ea7a2609721cc28649b8c50c752ef09 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Mon, 9 May 2022 00:00:22 +0100 Subject: [PATCH] Adjust readme and error report for CDB env var Further work on 4e024464739fe314855ef66e797ae45cb23007be --- README.rst | 12 ++++++------ cdb | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index afb18cb..7f3be8b 100644 --- a/README.rst +++ b/README.rst @@ -102,7 +102,7 @@ We can generate the list of files we don't know about using ``find`` and ``cdb filterpath``:: find ${DIR} -type f -print0 | \ - cdb --db ${DB} filterpath --inul --format '$u$z' --nul > ${DB}.new-files0 + cdb filterpath -1 -P -p out -0 -f '$u$z' > ${DB}.new-files0 .. _xargs_sha: @@ -127,7 +127,7 @@ file system as follows:: This database may not seem very useful, but when combined with ``cdb --db diff`` we can quickly find all paths whose checksums are unknown to the database:: - cdb --db ${DB} diff ${JPDB} --flavor=path --which=super --format '$u$z' --nul > ${DB}.new-files0 + cdb diff ${JPDB} --no-headers --flavor=path --which=super --format '$u$z' -0 > ${DB}.new-files0 And then proceed as `above `_. @@ -147,9 +147,9 @@ Armed with a "just paths" database as per the above, we can then direct the database to prune tracked paths not in the "just paths" database if the hashes are observed elsewhere:: - cdb --db ${DB} diff ${JPDB} --flavor=path --which=sub --no-headers --format '$u$z' --nul > ${JPDB}.missing-files0 - cdb --db ${DB} domv --inul < ${JPDB}.missing-files0 - cdb --db ${DB} gc > ${DB}.gc + cdb diff ${JPDB} --flavor=path --which=sub --no-headers --format '$u$z' --nul > ${JPDB}.missing-files0 + cdb domv --inul < ${JPDB}.missing-files0 + cdb gc > ${DB}.gc sqlite3 ${DB} < ${DB}.gc .. TODO or if the observed digest is now superseded? @@ -242,7 +242,7 @@ presence elsewhere in the database. We can enumerate files not tracked using above:: find ${DIR} -type f -print0 | \ - cdb --db ${DB} filterpath --in-path --predicate=out -0 -1 --format '$u$z' | \ + cdb filterpath --in-path --predicate=out -0 -1 --format '$u$z' | \ xargs -0 sha512sum > ${DB}.new We can then prepare to prune duplicates and add unique files:: diff --git a/cdb b/cdb index 1bad82c..a88a3c7 100755 --- a/cdb +++ b/cdb @@ -1139,7 +1139,9 @@ for k,v in pairs(argp_groups) do argp:group(k, table.unpack(v)) end local args = argp:parse() -- io.stderr:write((require "pl.pretty").write(args), "\n") -if not args.database then argp:error("Database is required") end +if not args.database then + argp:error("Database is required; pass --db or set CDB env var") +end local dbh, err = dbi.Connect("SQLite3", args.database) if not dbh then -- 2.50.1