diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/dtas-archive | 6 | ||||
-rwxr-xr-x | bin/dtas-readahead | 2 | ||||
-rwxr-xr-x | bin/dtas-splitfx | 1 | ||||
-rwxr-xr-x | bin/dtas-tl | 38 |
4 files changed, 31 insertions, 16 deletions
diff --git a/bin/dtas-archive b/bin/dtas-archive index c88873e..7c0e4f7 100755 --- a/bin/dtas-archive +++ b/bin/dtas-archive @@ -1,5 +1,5 @@ #!/usr/bin/env ruby -# Copyright (C) 2015-2020 all contributors <dtas-all@nongnu.org> +# Copyright (C) all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true usage = "#$0 SOURCE DESTINATION" @@ -30,6 +30,7 @@ stats = false keep_going = false compression = [] comment = [] +match = nil OptionParser.new('', 24, ' ') do |op| op.banner = usage @@ -47,6 +48,7 @@ OptionParser.new('', 24, ' ') do |op| op.on('-r', '--repeat [COUNT]', 'number of times to check', Integer) do |r| repeat = r end + op.on('-m', '--match=REGEX', String) { |s| match = Regexp.new(s) } op.on('-s', '--quiet', '--silent') { silent = true } op.on('-h', '--help') do puts(op.to_s) @@ -55,6 +57,7 @@ OptionParser.new('', 24, ' ') do |op| op.parse!(ARGV) end +match ||= %r/./ comment.push('--comment', '') if comment.empty? dst = ARGV.pop @@ -67,6 +70,7 @@ src.each do |s| src_st = File.stat(s) if src_st.directory? Find.find(s) do |path| + path =~ match or next File.file?(path) or next dir = File.dirname(path) dir_st = File.stat(dir) diff --git a/bin/dtas-readahead b/bin/dtas-readahead index f2ab514..c61d317 100755 --- a/bin/dtas-readahead +++ b/bin/dtas-readahead @@ -25,7 +25,7 @@ w.req_ok('watch') c = DTAS::UNIXClient.new @max_ra = 30 * 1024 * 1024 null = DTAS.null -@redir = { err: null, out: null, in: null }.freeze +@redir = { err: null, out: null, in: null, rlimit_cpu: [ 1, 2 ] }.freeze require 'pp' def seek_to_cur_pos(cur_pid, fp) diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx index d0afc7b..17d915d 100755 --- a/bin/dtas-splitfx +++ b/bin/dtas-splitfx @@ -13,6 +13,7 @@ OptionParser.new('', 24, ' ') do |op| op.on('-n', '--dry-run') { opts[:dryrun] = true } op.on('-j', '--jobs [JOBS]', Integer) { |val| opts[:jobs] = val } # nil==inf op.on('-s', '--quiet', '--silent') { opts[:silent] = true } + op.on('-S', '--stats', 'run stats every track') { opts[:stats] = true } op.on('-f', '--filter FILTER') { |val| (opts[:filter] ||= []) << val } op.on('-D', '--no-dither') { opts[:no_dither] = true } op.on('-O', '--outdir OUTDIR') { |val| opts[:outdir] = val } diff --git a/bin/dtas-tl b/bin/dtas-tl index e58ee31..c7f4c83 100755 --- a/bin/dtas-tl +++ b/bin/dtas-tl @@ -43,7 +43,8 @@ def do_edit(c) track_id = $1.to_i orig_idx[track_id] = orig.size orig << track_id - tmp.write("#{Shellwords.escape(line)} =#{track_id}\n") + line = Shellwords.escape(line) if line.include?("\n") + tmp.write("#{line} =#{track_id}\n") end tmp.flush @@ -100,13 +101,8 @@ def do_edit(c) non_existent = [] add.each do |path, after_id| orig = path - path = Shellwords.split(path)[0] - path = File.expand_path(path) - unless File.exist?(path) - path = orig.dup - path = Shellwords.split(path)[0] - path = File.expand_path(path) - end + path = File.expand_path(orig) + path = File.expand_path(Shellwords.split(path)[0]) unless File.exist?(path) if File.exist?(path) cmd = %W(tl add #{path}) @@ -142,6 +138,8 @@ case cmd = ARGV[0] when 'cat' each_track(c) { |line| print "#{line}\n" } when 'prune' + c2 = nil + pending = 0 each_track(c) do |line| line.sub!(/\A(\d+)=/n, '') or abort "unexpected line=#{line.inspect}\n" track_id = $1.to_i @@ -153,7 +151,19 @@ when 'prune' warn "# #{line}: #{e.class}" # raise other exceptions end - c.req("tl remove #{track_id}") unless ok + unless ok + c2 ||= DTAS::UNIXClient.new + if pending > 5 + c2.res_wait + pending -= 1 + end + pending += 1 + c2.req_start("tl remove #{track_id}") + end + end + while pending > 0 + c2.res_wait + pending -= 1 end when 'aac' # add-after-current ARGV.shift @@ -178,11 +188,11 @@ when "reto" re = ARGV[1] time = ARGV[2] re = Regexp.quote(re) if fixed - re = ignorecase ? %r{#{re}}i : %r{#{re}} - get_track_ids(c).each do |track_id| - res = c.req("tl get #{track_id}") - res.sub!(/\A1 \d+=/, '') - if re =~ res + re = ignorecase ? %r{#{re}}in : %r{#{re}}n + each_track(c) do |line| + line.sub!(/\A(\d+)=/n, '') or abort "unexpected line=#{line.inspect}\n" + track_id = $1 + if re =~ line req = %W(tl goto #{track_id}) req << time if time res = c.req(req) |