- file = rep.raw_path
- next if !file or rep.binary?
-
- if system("gzip", "-ck9", file, [:out]=>[file + ".gz.tmp", "wb"])
- system("touch", "-r", file, file + ".gz.tmp")
- File.rename(file + ".gz.tmp", file + ".gz")
- else
- File.unlink(file + ".gz.tmp")
+ next if rep.binary?
+ rep.instance_variable_get(:@item_rep).raw_paths[:last].each do |f|
+ if system("gzip", "-nck9", f, [:out]=>["#{f}.gz.tmp", "wb"])
+ system("touch", "-r", f, "#{f}.gz.tmp")
+ File.rename("#{f}.gz.tmp", "#{f}.gz")
+ else
+ File.unlink("#{f}.gz.tmp")
+ end
+ end
+ end
+ end
+
+ # Register URLs for git-annex keys
+ unless (uribase = ENV['ANNEX_URI_BASE'].to_s.chomp("/")).empty?
+ Open3.popen2("git", "-c", "core.bare=false", "annex", "registerurl") do
+ |stdin, stdout, result|
+ @items.each do |item|
+ next if item.raw_filename.nil?
+
+ l = File.readlink(item.raw_filename)
+ next unless l =~ %r{/annex/objects/}
+
+ key = File.basename(l)
+
+ # Find output reps corresponding to this key, if any
+ item.reps.each do |rep|
+ next if rep.raw_path.nil?
+ next unless
+ FileUtils.identical?(item.raw_filename, rep.raw_path)
+
+ loop do
+ STDOUT.write(stdout.read_nonblock(100))
+ rescue EOFError, IO::WaitReadable
+ break
+ end
+
+ stdin.printf("%s %s%s\n", key, uribase, rep.path)
+ end
+ rescue Errno::EINVAL
+ end
+
+ stdin.close
+ loop do
+ STDOUT.write(stdout.readpartial(100))
+ rescue EOFError
+ break
+ end
+
+ unless (rc = result.value).success?
+ printf("git annex registerurl failed: %s\n", rc.to_s)