only when adding new albums

This commit is contained in:
Espen Antonsen 2009-08-10 22:19:37 +02:00
parent fab8ba652a
commit 27bd06c0c8

View file

@ -16,30 +16,26 @@ module ScanFiles
relpath = File.dirname( path ).sub(APP_CONFIG[:photos_path], '') relpath = File.dirname( path ).sub(APP_CONFIG[:photos_path], '')
relfile = path.sub(APP_CONFIG[:photos_path], '') relfile = path.sub(APP_CONFIG[:photos_path], '')
puts relpath puts relpath
album = Album.find_by_path( relpath )
if prevalbum != relpath
puts relpath
prevalbum = relpath
end
if album.nil?
relpathdirs = relpath.split("/") relpathdirs = relpath.split("/")
relpathparam = "" relpathparam = ""
relpathdirs.each{|d| relpathdirs.each{|d|
relpathparam += d.parameterize + "/" relpathparam += d.parameterize + "/"
} }
relpathparam = relpathparam.slice(0..relpathparam.length-2) relpathparam = relpathparam.slice(0..relpathparam.length-2)
album = Album.find_by_path( relpath )
if relpath != relpathparam if relpath != relpathparam
puts APP_CONFIG[:photos_path] + relpath + " will now be moved to " + APP_CONFIG[:photos_path] + 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 FileUtils.mv APP_CONFIG[:photos_path] + relpath, APP_CONFIG[:photos_path] + relpathparam
puts "reload!" puts "reload!"
unless album.nil?
album.path = relpathparam
album.save!
end
self.FullScan self.FullScan
return return
end end
if prevalbum != relpath
puts relpath
prevalbum = relpath
end
if album.nil?
puts "New album : " + File.basename( relpath ) puts "New album : " + File.basename( relpath )
album = Album.new() album = Album.new()
album.path = relpath album.path = relpath