44 * are made available under the terms of the GNU Public License v2.0
55 * which accompanies this distribution, and is available at
66 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
7- *
7+ *
88 * Contributors:
99 * Matthieu Helleboid - initial API and implementation
1010 ******************************************************************************/
2020import org .piwigo .remotesync .api .Constants ;
2121import org .piwigo .remotesync .api .ISyncConfiguration ;
2222import org .piwigo .remotesync .api .cache .LegacyCache ;
23+ import org .piwigo .remotesync .menalto .Importer ;
2324import org .slf4j .Logger ;
2425import org .slf4j .LoggerFactory ;
2526
@@ -30,10 +31,12 @@ public abstract class SyncDirectoryWalker extends DirectoryWalker<File> {
3031 protected ISyncConfiguration syncConfiguration ;
3132 protected File startDirectory ;
3233 protected Map <File , LegacyCache > legacyCaches = new HashMap <File , LegacyCache >();
34+ private Importer importer ;
3335
3436 protected SyncDirectoryWalker (ISyncConfiguration syncConfiguration ) {
3537 super (null , Constants .IMAGE_EXTENSIONS_FILTER , -1 );
3638 this .syncConfiguration = syncConfiguration ;
39+ importer = new Importer (syncConfiguration .getDirectory ());
3740 }
3841
3942 @ Override
@@ -55,7 +58,9 @@ protected void handleDirectoryStart(File directory, int depth, Collection<File>
5558 // FIXME : ignore me
5659 }
5760 logger .info ("Creating album for " + directory );
58- legacyCache .addAlbum (createAlbum (directory , parentAlbumId ));
61+ Integer albumId = createAlbum (directory , parentAlbumId );
62+ legacyCache .addAlbum (albumId );
63+ importer .addAlbum (directory .getAbsolutePath (), albumId );
5964 }
6065 }
6166
@@ -72,7 +77,9 @@ protected void handleFile(File file, int depth, java.util.Collection<File> resul
7277 // FIXME : ignore me
7378 }
7479 logger .info ("Uploading " + file .getName () + " in album with ID " + albumId );
75- legacyCache .addImage (file , createImage (file , albumId ));
80+ Integer imageId = createImage (file , albumId );
81+ legacyCache .addImage (file , imageId );
82+ importer .addImage (file .getAbsolutePath (), albumId , imageId );
7683 }
7784 }
7885
0 commit comments