File: convert-git-annex-layout

package info (click to toggle)
datalad 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,148 kB
  • sloc: python: 69,414; sh: 1,521; makefile: 220
file content (31 lines) | stat: -rwxr-xr-x 880 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

set -eu

to="$1"

echo "Initial fsck:"
git annex fsck --fast 2>&1 | python -m tqdm --null
echo "Going through objects: "
for f in .git/annex/objects/*/*/*; do
    key=$(basename $f)
    keydir=$(dirname $f)
    newhashdir=$(git annex examinekey --format="\${$to}" "$key")
    targetdir=".git/annex/objects/$newhashdir"
    test -n "$newhashdir"
    if [ "$keydir" = "${targetdir%/}" ]; then
        continue
    fi
    echo "  $f -> $newhashdir"
    # This was a wrong assumption - there could be multiple
    # keys in the same directory so we might have it already.
    # But I still feel we might need some test here
    #if test -e "$targetdir"; then
    #    echo "$targetdir already exists"
    #    exit 1
    #fi
    mkdir -p "$(dirname $targetdir)"
    mv "$keydir" "${targetdir%/}"
done
echo "Final fsck:"
git annex fsck --fast 2>&1 | python -m tqdm --null