diff options
| author | Přemysl Eric Janouch <p@janouch.name> | 2023-12-29 14:54:17 +0100 | 
|---|---|---|
| committer | Přemysl Eric Janouch <p@janouch.name> | 2023-12-29 14:54:17 +0100 | 
| commit | 644bcefd71339d58483f1a7c4a94ac7ff9c4dc75 (patch) | |
| tree | e0f301d4f7ec676219c917ad5e5c2b747a5f20e7 | |
| parent | 19db1b17c184cca2073bf395568a4841953d2629 (diff) | |
| download | gallery-original.tar.gz gallery-original.tar.xz gallery-original.zip | |
Resolve issuesoriginal
| -rw-r--r-- | main.go | 8 | ||||
| -rwxr-xr-x | test.sh | 50 | 
2 files changed, 46 insertions, 12 deletions
| @@ -1638,9 +1638,7 @@ func syncRoot(c *syncContext, dbPath []string, fsPath string) error {  			FROM node AS n JOIN subtree AS s ON n.parent = s.id  		) DELETE FROM node WHERE id IN (  			SELECT id FROM subtree WHERE level <> 1 AND sha1 IS NULL -			-- No idea why one can't put the "node" table in the subselect. -			-- The whole query then matches nothing. -			AND id NOT IN (SELECT parent FROM subtree) +			AND id NOT IN (SELECT parent FROM node WHERE parent IS NOT NULL)  		)`)  	if err != nil {  		return err @@ -2283,7 +2281,7 @@ func (l *linearImage) At(x, y int) color.Color {  // isWebPAnimation returns whether the given ReadSeeker starts a WebP animation.  // See https://developers.google.com/speed/webp/docs/riff_container  func isWebPAnimation(rs io.ReadSeeker) (bool, error) { -	b := make([]byte, 17) +	b := make([]byte, 21)  	if _, err := rs.Read(b); err != nil {  		return false, err  	} @@ -2293,7 +2291,7 @@ func isWebPAnimation(rs io.ReadSeeker) (bool, error) {  	return bytes.Equal(b[:4], []byte("RIFF")) &&  		bytes.Equal(b[8:16], []byte("WEBPVP8X")) && -		b[16]&0b00000010 != 0, nil +		b[20]&0b00000010 != 0, nil  }  var errIsAnimation = errors.New("cannot perceptually hash animations") @@ -1,17 +1,53 @@  #!/bin/sh -xe  cd "$(dirname "$0")"  make gallery -target=/tmp/G input=/tmp/G/Images +target=/tmp/G input=/tmp/G/Test  rm -rf $target -mkdir -p $target $input -# TODO: Generate something in there. +mkdir -p $target $input/Test $input/Empty +gen() { magick "$@"; sha1=$(sha1sum "$(eval echo \$\{$#\})" | cut -d' ' -f1); } + +gen wizard: $input/wizard.webp +gen -seed 10 -size 256x256 plasma:fractal \ +	$input/Test/dhash.jpg +gen -seed 10 -size 256x256 plasma:fractal \ +	$input/Test/dhash.png +sha1duplicate=$sha1 +cp $input/Test/dhash.png \ +	$input/Test/multiple-paths.png + +gen -seed 20 -size 160x128 plasma:fractal \ +	-bordercolor transparent -border 64 \ +	$input/Test/transparent-wide.png +gen -seed 30 -size 1024x256 plasma:fractal \ +	-alpha set -channel A -evaluate multiply 0.2 \ +	$input/Test/translucent-superwide.png + +gen -size 96x96 -delay 10 -loop 0 \ +	-seed 111 plasma:fractal \ +	-seed 222 plasma:fractal \ +	-seed 333 plasma:fractal \ +	-seed 444 plasma:fractal \ +	-seed 555 plasma:fractal \ +	-seed 666 plasma:fractal \ +	$input/Test/animation-small.gif +sha1animated=$sha1 +gen $input/Test/animation-small.gif \ +	$input/Test/video.mp4  ./gallery init $target  ./gallery sync $target $input "$@"  ./gallery thumbnail $target  ./gallery dhash $target -./gallery tag $target test "Test space" < /dev/null +./gallery tag $target test "Test space" <<-END +	$sha1duplicate	foo	1.0 +	$sha1duplicate	bar	0.5 +	$sha1animated	foo	0.8 +END + +# TODO: Test all the various possible sync transitions. +mv $input/Test $input/Plasma +./gallery sync $target $input  ./gallery web $target :8080 &  web=$! @@ -20,10 +56,10 @@ sleep 0.25  call() (curl http://localhost:8080/api/$1 -X POST --data-binary @-) +# TODO: Verify that things are how we expect them to be.  echo '{"path":"'"$(basename "$input")"'"}' | call browse  echo '{}' | call tags  echo '{}' | call duplicates  echo '{}' | call orphans -# TODO: Use hashes of generated images. -echo '{"sha1":"d53fc82162fd19a6e7b92b401b08b7505dbf3dfd"}' | call info -echo '{"sha1":"9539d9895ab8c25d76c321b23b8a327801a496bb"}' | call similar +echo '{"sha1":"'"$sha1duplicate"'"}' | call info +echo '{"sha1":"'"$sha1duplicate"'"}' | call similar | 
