about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-01-25 01:10:00 +0000
committerEric Wong <e@80x24.org>2016-01-25 01:10:00 +0000
commitf7c67ab312f55dfc153f96e6b8a09b34bb322b07 (patch)
tree5cfea6f5fd00da64135b5f8313f777d8bcdc0738
parent70b81da26a525486c288176e5764c875c752d0b8 (diff)
downloaddtas-f7c67ab312f55dfc153f96e6b8a09b34bb322b07.tar.gz
We will allow forcing updates since upgrading dependent software
(e.g. sox, avprobe, ffprobe) may allow previously-ignored files
to become support
-rwxr-xr-xbin/dtas-mlib4
-rw-r--r--lib/dtas/mlib.rb7
2 files changed, 8 insertions, 3 deletions
diff --git a/bin/dtas-mlib b/bin/dtas-mlib
index 5fa2b63..28fef97 100755
--- a/bin/dtas-mlib
+++ b/bin/dtas-mlib
@@ -10,11 +10,13 @@ require 'dtas/mlib'
 require 'optparse'
 path = '~/.dtas/mlib.sqlite'
 db = File.expand_path(path)
+force = false
 OptionParser.new('', 24, '  ') do |op|
   op.banner = usage
   op.on('-d', '--database <URI|PATH>', "database (default: #{path}") do |d|
     db = d
   end
+  op.on('-f', '--force', 'force updates') { force = true }
   op.on('-h', '--help') do
     puts(op.to_s)
     exit
@@ -39,7 +41,7 @@ end
 case action = ARGV.shift
 when 'update', 'up'
   directory = ARGV.shift or abort "DIRECTORY required\n#{usage}"
-  mlib(db, migrate = true).update(directory)
+  mlib(db, migrate = true).update(directory, force: force)
 when 'stats'
   s = mlib(db, true).stats
   %w(artists albums songs db_playtime).each { |k| puts "#{k}: #{s[k.to_sym]}" }
diff --git a/lib/dtas/mlib.rb b/lib/dtas/mlib.rb
index 3bfed8f..ffd0cc3 100644
--- a/lib/dtas/mlib.rb
+++ b/lib/dtas/mlib.rb
@@ -145,6 +145,7 @@ class DTAS::Mlib # :nodoc:
     # this generates
     opts ||= {}
     jobs = opts[:jobs] || 8
+    @force = opts[:force] || false
 
     init_suffixes
     st = File.stat(path) # we always follow the first dir even if it's a symlink
@@ -208,8 +209,10 @@ class DTAS::Mlib # :nodoc:
     return if @suffixes !~ path || st.size == 0
 
     # no-op if no change
-    if node = @db[:nodes][name: path, parent_id: parent_id]
-      return if st.ctime.to_i == node[:ctime] || node[:tlen] == DM_IGN
+    unless @force
+      if node = @db[:nodes][name: path, parent_id: parent_id]
+        return if st.ctime.to_i == node[:ctime] || node[:tlen] == DM_IGN
+      end
     end
 
     job = Job.new(@pwd, st.ctime.to_i, parent_id, path)