Page MenuHomeSoftware Heritage

import-oversize

Authored By
zack
Nov 3 2017, 2:34 PM
Size
833 B
Subscribers
None

import-oversize

#!/bin/bash
oversize_list="/srv/storage/space/lists/oversize-contents.txt.xz"
objstorage_root="/srv/softwareheritage/objects"
oversize_root="/srv/softwareheritage/oversize-objects"
dry_run="y"
act () {
if [ "$dry_run" = "y" ] ; then
echo "* dry run: $@"
else
"$@"
fi
}
warn () {
echo "* WARNING: $1"
}
xzcat "$oversize_list" |
while read obj_id ; do
old_path="${objstorage_root}/${obj_id:0:2}/${obj_id:2:2}/${obj_id:4:2}/${obj_id}"
new_path="${oversize_root}/${obj_id:0:2}/${obj_id:2:2}/${obj_id}"
new_dir=$(dirname $new_path)
if ! [ -f "$old_path" ] ; then
warn "cannot found oversize object $obj_id, skipping"
continue
fi
if ! [ -d "$new_dir" ] ; then
act mkdir -p "$new_dir"
fi
if ! [ -f "$new_path" ] ; then
act cp -a "$old_path" "${new_path}.new"
act mv "${new_path}.new" "$new_path"
fi
done

File Metadata

Mime Type
text/x-shellscript
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
204801

Event Timeline

zack changed the visibility from "zack (Stefano Zacchiroli)" to "Public (No Login Required)".Nov 3 2017, 2:37 PM