Make import --deduplicate and --skip-duplicates only hash once, not twice

import: --deduplicate and --skip-duplicates were implemented inneficiently;
they unncessarily hashed each file twice. They have been improved to only
hash once.

The new approach is to lock down (minimally) and hash files, and then
reuse that information when importing them.

This was rather tricky, especially in detecting changes to files while
they are being imported.

The output of import changed slightly. While before it silently skipped
over files with eg --skip-duplicates, now it shows each file as it starts
to act on it. Since every file is hashed first thing, it would otherwise
not be clear what file import is chewing on. (Actually, it wasn't clear
before when any of the duplicates switches were used.)

This commit was sponsored by Alexander Thompson on Patreon.
This commit is contained in:
Joey Hess 2017-02-09 15:32:22 -04:00
parent 30ab4ecc4b
commit f617988a29
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
5 changed files with 90 additions and 41 deletions

View file

@ -88,7 +88,7 @@ clean file = do
<$> catKeyFile file
liftIO . emitPointer
=<< go
=<< ingest' currbackend
=<< (\ld -> ingest' currbackend ld Nothing)
=<< lockDown cfg file
, liftIO $ B.hPut stdout b
)