prepare_data now only processes files based on modification time
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 5 Nov 2017 02:23:13 +0000 (04:23 +0200)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 5 Nov 2017 02:23:13 +0000 (04:23 +0200)
tools/prepare_data

index c1bf5f8..7106581 100755 (executable)
@@ -4,6 +4,7 @@ indir=datasrc
 descfile=$indir/datadesc
 outdir=data
 filter=$1
+force_update=false
 
 process()
 {
@@ -34,6 +35,14 @@ copy()
        fi
 }
 
+for arg; do
+       case "$arg" in
+       -f)
+               force=true
+               ;;
+       esac
+done
+
 if [ -z "$filter" ]; then
        filter='.*'
 fi
@@ -47,14 +56,23 @@ while read line; do
         fname=$(basename $path)
         op=$(echo $line | awk -F : '{ print $2; }' | xargs)
 
-        if [ "$op" = nop ]; then
-            echo copying $fname
-            mkdir -p $outdir/$(dirname $path)
-            copy $indir/$path $outdir/$path
-        else
-            echo processing $fname
-            mkdir -p $outdir/$(dirname $path)
-            process $indir/$path $outdir/$path "$op"
-        fi
+               infile=$indir/$path
+               outfile=$outdir/$path
+
+               if $force_update; then
+                       touch "$infile"
+               fi
+
+               if [ "$infile" -nt "$outfile" ]; then
+                       if [ "$op" = nop ]; then
+                               echo copying $fname
+                               mkdir -p $outdir/$(dirname $path)
+                               copy $indir/$path $outdir/$path
+                       else
+                               echo processing $fname
+                               mkdir -p $outdir/$(dirname $path)
+                               process $indir/$path $outdir/$path "$op"
+                       fi
+               fi
     fi
 done <$descfile