From 27bd06c0c8ee04d3c683f897c0e48590f8c7665d Mon Sep 17 00:00:00 2001 From: Espen Antonsen Date: Mon, 10 Aug 2009 22:19:37 +0200 Subject: [PATCH] only when adding new albums --- lib/scan.rb | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/lib/scan.rb b/lib/scan.rb index 4604a92..b8a3eb3 100644 --- a/lib/scan.rb +++ b/lib/scan.rb @@ -16,30 +16,26 @@ module ScanFiles relpath = File.dirname( path ).sub(APP_CONFIG[:photos_path], '') relfile = path.sub(APP_CONFIG[:photos_path], '') puts relpath - relpathdirs = relpath.split("/") - relpathparam = "" - relpathdirs.each{|d| - relpathparam += d.parameterize + "/" - } - relpathparam = relpathparam.slice(0..relpathparam.length-2) album = Album.find_by_path( relpath ) - if relpath != relpathparam - puts APP_CONFIG[:photos_path] + relpath + " will now be moved to " + APP_CONFIG[:photos_path] + relpathparam - FileUtils.mv APP_CONFIG[:photos_path] + relpath, APP_CONFIG[:photos_path] + relpathparam - puts "reload!" - unless album.nil? - album.path = relpathparam - album.save! - end - self.FullScan - return - end - if prevalbum != relpath puts relpath prevalbum = relpath end if album.nil? + relpathdirs = relpath.split("/") + relpathparam = "" + relpathdirs.each{|d| + relpathparam += d.parameterize + "/" + } + relpathparam = relpathparam.slice(0..relpathparam.length-2) + if relpath != relpathparam + puts APP_CONFIG[:photos_path] + relpath + " will now be moved to " + APP_CONFIG[:photos_path] + relpathparam + FileUtils.mv APP_CONFIG[:photos_path] + relpath, APP_CONFIG[:photos_path] + relpathparam + puts "reload!" + self.FullScan + return + end + puts "New album : " + File.basename( relpath ) album = Album.new() album.path = relpath