@@ -29,24 +29,30 @@ function getAncestryIds(canonicalId: string): { treeId: string; ancestryPersonId
2929}
3030
3131/**
32- * Find the best local photo for a person (same priority as FS upload)
32+ * Find the best local photo for uploading TO Ancestry.
33+ * Prioritizes non-Ancestry photos since we want to upload new content.
34+ * Falls back to the generic photo, then ancestry as last resort (for re-upload).
3335 */
34- function findLocalPhoto ( canonicalId : string ) : { path : string ; url : string } | null {
36+ function findLocalPhoto ( canonicalId : string ) : { path : string ; url : string ; isFromAncestry : boolean } | null {
3537 const photosDir = join ( DATA_DIR , 'photos' ) ;
38+ // Priority: familysearch > wikitree > wiki > generic > ancestry (last resort)
3639 const photoChecks = [
37- { suffix : '-ancestry' , path : join ( photosDir , `${ canonicalId } -ancestry.jpg` ) , url : `/augment/${ canonicalId } /ancestry-photo` } ,
38- { suffix : '-ancestry' , path : join ( photosDir , `${ canonicalId } -ancestry.png` ) , url : `/augment/${ canonicalId } /ancestry-photo` } ,
39- { suffix : '-wikitree' , path : join ( photosDir , `${ canonicalId } -wikitree.jpg` ) , url : `/augment/${ canonicalId } /wikitree-photo` } ,
40- { suffix : '-wikitree' , path : join ( photosDir , `${ canonicalId } -wikitree.png` ) , url : `/augment/${ canonicalId } /wikitree-photo` } ,
41- { suffix : '-wiki' , path : join ( photosDir , `${ canonicalId } -wiki.jpg` ) , url : `/augment/${ canonicalId } /wiki-photo` } ,
42- { suffix : '-wiki' , path : join ( photosDir , `${ canonicalId } -wiki.png` ) , url : `/augment/${ canonicalId } /wiki-photo` } ,
43- { suffix : '' , path : join ( photosDir , `${ canonicalId } .jpg` ) , url : `/browser/photos/${ canonicalId } ` } ,
44- { suffix : '' , path : join ( photosDir , `${ canonicalId } .png` ) , url : `/browser/photos/${ canonicalId } ` } ,
40+ { path : join ( photosDir , `${ canonicalId } -familysearch.jpg` ) , url : `/augment/${ canonicalId } /familysearch-photo` , isFromAncestry : false } ,
41+ { path : join ( photosDir , `${ canonicalId } -familysearch.png` ) , url : `/augment/${ canonicalId } /familysearch-photo` , isFromAncestry : false } ,
42+ { path : join ( photosDir , `${ canonicalId } -wikitree.jpg` ) , url : `/augment/${ canonicalId } /wikitree-photo` , isFromAncestry : false } ,
43+ { path : join ( photosDir , `${ canonicalId } -wikitree.png` ) , url : `/augment/${ canonicalId } /wikitree-photo` , isFromAncestry : false } ,
44+ { path : join ( photosDir , `${ canonicalId } -wiki.jpg` ) , url : `/augment/${ canonicalId } /wiki-photo` , isFromAncestry : false } ,
45+ { path : join ( photosDir , `${ canonicalId } -wiki.png` ) , url : `/augment/${ canonicalId } /wiki-photo` , isFromAncestry : false } ,
46+ { path : join ( photosDir , `${ canonicalId } .jpg` ) , url : `/browser/photos/${ canonicalId } ` , isFromAncestry : false } ,
47+ { path : join ( photosDir , `${ canonicalId } .png` ) , url : `/browser/photos/${ canonicalId } ` , isFromAncestry : false } ,
48+ // Ancestry photos last - only for re-upload scenarios
49+ { path : join ( photosDir , `${ canonicalId } -ancestry.jpg` ) , url : `/augment/${ canonicalId } /ancestry-photo` , isFromAncestry : true } ,
50+ { path : join ( photosDir , `${ canonicalId } -ancestry.png` ) , url : `/augment/${ canonicalId } /ancestry-photo` , isFromAncestry : true } ,
4551 ] ;
4652
4753 for ( const check of photoChecks ) {
4854 if ( existsSync ( check . path ) ) {
49- return { path : check . path , url : check . url } ;
55+ return { path : check . path , url : check . url , isFromAncestry : check . isFromAncestry } ;
5056 }
5157 }
5258 return null ;
@@ -71,11 +77,11 @@ export const ancestryUploadService = {
7177 const ancestryPngPath = join ( DATA_DIR , 'photos' , `${ canonical } -ancestry.png` ) ;
7278 const ancestryHasPhoto = existsSync ( ancestryPhotoPath ) || existsSync ( ancestryPngPath ) ;
7379
74- // Photo differs if we have a local photo from a non-Ancestry source
75- const photoDiffers = localPhoto !== null && (
76- ! ancestryHasPhoto ||
77- ! localPhoto . path . includes ( '- ancestry' )
78- ) ;
80+ // Photo differs (i.e., we should offer upload) if:
81+ // 1. We have a local photo to upload, AND
82+ // 2. The best photo is NOT from ancestry (meaning we have a better source)
83+ // If the only photo is from ancestry, photoDiffers=false (nothing new to upload )
84+ const photoDiffers = localPhoto !== null && ! localPhoto . isFromAncestry ;
7985
8086 return {
8187 photo : {
0 commit comments