public void processMTRoot(String path) { long t0 = System.currentTimeMillis(); DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); Date date = new Date(); try { ts.addIndexPath(new File(path).getCanonicalPath()); System.out.println("MediaIndexer.processMTRoot()" + path); System.out.println("MediaIndexer.processMTRoot() started at time " + dateFormat.format(date)); System.out.println("MediaIndexer.processMTRoot() computing number of files..."); totalNumberOfFiles = this.countFiles(path); lastProgressTime = System.currentTimeMillis(); System.out.println("Number of files to explore " + totalNumberOfFiles); if (executorService.isShutdown()) { executorService = new ThreadPoolExecutor( maxThreads, maxThreads, 0L, TimeUnit.MILLISECONDS, new LimitedQueue<Runnable>(50)); } this.processedFiles = 0; // this.processMT(new File(path)); TreeWalker t = new TreeWalker(this); t.walk(path); } catch (IOException e) { e.printStackTrace(); } executorService.shutdown(); try { executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); } catch (InterruptedException e) { e.printStackTrace(); } long t1 = System.currentTimeMillis(); date = new Date(); System.out.println("MediaIndexer.processMTRoot() finished at time " + dateFormat.format(date)); System.out.println("MediaIndexer.processMTRoot() found " + newFiles + " new files"); System.out.println("MediaIndexer.processMTRoot() updated " + updatedFiles + " files"); System.out.println("MediaIndexer.processMTRoot() total " + ts.size() + " files"); System.out.println("MediaIndexer.processMTRoot took " + (t1 - t0) / 1000 + " s"); }
public void updateDB() { this.updateDB(ts.getIndexedPaths().toArray(new String[] {})); }
private void updateToDB(MediaFileDescriptor id) { if (!dryRun) { ts.updateToDB(id); } }
private void saveToDB(MediaFileDescriptor id) { if (!dryRun) { ts.saveToDB(id); } }
public void generateAndSave(File f) { System.out.print("."); currentProgressSize += f.length() / 1024; try { MediaFileDescriptor mf = ts.getMediaFileDescriptor(f.getCanonicalPath()); Logger.getLogger().err("MediaIndexer.generateAndSave " + f + " descriptor: " + mf); if ((mf != null) && (f.lastModified() == mf.getMtime())) { // Descriptor exists with same mtime Logger.getLogger() .err("MediaIndexer.generateImageDescriptor() Already in DB, ignoring with same mtime"); Logger.getLogger().err("MediaIndexer.generateImageDescriptor() In DB : " + mf.getMtime()); Logger.getLogger() .err("MediaIndexer.generateImageDescriptor() On Disk : " + f.lastModified()); boolean update = false; if (forceGPSUpdate) { // MediaFileDescriptor mfd = ts.getMediaFileDescriptor(f.getCanonicalPath()); MetaDataFinder mdf = new MetaDataFinder(f); double latLon[] = mdf.getLatLong(); Logger.getLogger().err("MediaIndexer.generateAndSave working on " + f); if (latLon != null) { mf.setLat(latLon[0]); mf.setLon(latLon[1]); Logger.getLogger().err("MediaIndexer : forced update for GPS data for " + f); updateToDB(mf); update = true; } } if (forceHashUpdate || (mf.getHash() == null)) { if (Utils.isValideImageName(f.getName())) { mf.setHash(new ImageHash().generateSignature(f.getCanonicalPath())); updateToDB(mf); update = true; } } // if (update) { this.fileCreatedUpdated(false, update); // } } else { Logger.getLogger().err("MediaIndexer.generateAndSave building descriptor"); MediaFileDescriptor id = this.buildMediaDescriptor(f); if (id != null) { if ((mf != null) && (f.lastModified() != mf.getMtime())) { // we need to update it updateToDB(id); this.fileCreatedUpdated(false, true); } else { saveToDB(id); this.fileCreatedUpdated(true, false); } if (log.isEnabled()) { log.log( f.getCanonicalPath() + " ..... size " + (f.length() / 1024) + " KiB OK " + executorService.getActiveCount() + " threads running"); } } else { this.fileCreatedUpdated(false, false); } } } catch (IOException e) { System.err.println("Error processing file " + f.getName()); e.printStackTrace(); } }