@ -2,6 +2,7 @@ package main
import (
import (
"os"
"os"
"errors"
"io/fs"
"io/fs"
"fmt"
"fmt"
"path/filepath"
"path/filepath"
@ -124,7 +125,20 @@ func GetConversion(config Settings, path string) Conversion {
return config . Base
return config . Base
}
}
func RenderImages ( config Settings ) error {
func HasChanged ( old_info fs . FileInfo , new_path string ) bool {
new_info , err := os . Stat ( new_path )
if errors . Is ( err , fs . ErrNotExist ) {
return true
} else if err != nil {
log . Printf ( "!!!! can't stat target: %s: %v" , new_path , err )
return false
}
return old_info . ModTime ( ) . After ( new_info . ModTime ( ) )
}
func RenderImages ( config Settings , force bool ) error {
err := filepath . WalkDir ( config . Source ,
err := filepath . WalkDir ( config . Source ,
func ( path string , d fs . DirEntry , err error ) error {
func ( path string , d fs . DirEntry , err error ) error {
if ! d . IsDir ( ) && Included ( config , path ) {
if ! d . IsDir ( ) && Included ( config , path ) {
@ -137,7 +151,15 @@ func RenderImages(config Settings) error {
fmt . Println ( "FILE: " , path , "TARGET:" , target )
fmt . Println ( "FILE: " , path , "TARGET:" , target )
convert := GetConversion ( config , path )
convert := GetConversion ( config , path )
JankImage ( convert , path , target )
path_info , err := d . Info ( )
if err != nil {
log . Fatalf ( "failed to stat %s: %v" , path , err )
}
if force || HasChanged ( path_info , target ) {
JankImage ( convert , path , target )
}
} else {
} else {
fmt . Println ( "SKIP:" , path )
fmt . Println ( "SKIP:" , path )
}
}