mediafile 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1dbbce1323dc0990bbc33da1ec6dafbd36bd119
4
- data.tar.gz: 50f4d1f802f3bef3dec4b2a4d2afc37d755ad6d7
3
+ metadata.gz: 0cf95d2ef90842833ff1684e63e819eb786eb3b6
4
+ data.tar.gz: bf5437da339bcd635853b6cb2535b25914d14691
5
5
  SHA512:
6
- metadata.gz: 992909477ae50eaa4cba726c48f2472f87ea44beaf87d511048a8363ccb6abd7646779982f46d39cf6a39aa865ffd28367ff116a65cd9f8f827906e027cdcde8
7
- data.tar.gz: 2d40a4d6cb26d86cb6088d959ae70ccad61e8cbec39c9ddac27ef8664e47d95d91428f85d49358884e8eca5f6f24c0db1e54d8fcd7d78864c8d3bf538a339861
6
+ metadata.gz: b9d7f53933c2b36e4788153a90109adfff0732d752ae6b55f39e69dace58a6b927904ae495792a5c8322e1e4e1f33aa7bbfc026b2ba2b2a4aa14fb5ead42c360
7
+ data.tar.gz: c14b16bf4336633b6322c9b8b9dca487e30b1d134d1cff43904d4e54f285e7d2c4d710523e3072b6177b168dc4089507fb71413a2e9fce06c37b989c5166cfca
@@ -43,21 +43,21 @@ class MediaFile
43
43
  destination = out_path base_dir: dest, transcode_table: transcode_table
44
44
  temp_dest = tmp_path base_dir: dest, typ: transcode_table[@type]
45
45
  debug "temp dest is '#{temp_dest}'"
46
- lock{
47
- if File.exist?(temp_dest)
48
- error "File transfer is already in progress for #{@source} => #{temp_dest} => #{destination}"
49
- error "This shouldn't happen! Check to make sure it was really copied."
50
- raise
51
- #return
52
- end
53
- if File.exist?(destination)
54
- info("File has already been transfered #{@source} => #{destination}")
55
- return
56
- end
57
- debug("Create parent directories at '#{File.dirname destination}'.")
58
- FileUtils.mkdir_p File.dirname destination
59
- FileUtils.touch temp_dest
60
- }
46
+
47
+ if File.exist?(destination)
48
+ info("File already exists at destination: #{@source} => #{destination}")
49
+ return
50
+ end
51
+
52
+ unless record_transfer(temp_dest)
53
+ error "Two source files mapped to the same destination file!"
54
+ error "This file: #{@source} => #{temp_dest}"
55
+ return
56
+ end
57
+
58
+ debug("Create parent directories at '#{File.dirname destination}'.")
59
+ FileUtils.mkdir_p File.dirname destination
60
+ FileUtils.touch temp_dest
61
61
  begin
62
62
  transcode_table.has_key?(@type) ?
63
63
  transcode(transcode_table, temp_dest) :
@@ -1,3 +1,3 @@
1
1
  module MediaFile
2
- VERSION = "0.2.4" unless defined?(::MediaFile::VERSION)
2
+ VERSION = "0.2.5" unless defined?(::MediaFile::VERSION)
3
3
  end
data/lib/mediafile.rb CHANGED
@@ -5,7 +5,8 @@ require 'fileutils'
5
5
  require 'mkmf'
6
6
  require 'digest/md5'
7
7
  require 'timeout'
8
- require 'taglib'
8
+ require 'taglib'
9
+ require 'set'
9
10
  require 'mediafile/version'
10
11
 
11
12
  module MakeMakefile::Logging
@@ -38,15 +39,22 @@ module MediaFile
38
39
  @@thread_count = nil
39
40
  @@mutex = nil
40
41
  @@initialized = false
42
+ @@transfers = Set.new
43
+
44
+ def check_transfer(path)
45
+ lock {
46
+ @@transfers.add? path
47
+ }
48
+ end
41
49
 
42
50
  def initialize_threads(count = 1)
43
51
  return if @@initialized
44
- @@initialized = 1
45
52
  @@thread_count = count
46
53
  if @@thread_count > 1
47
54
  require 'thread'
48
55
  @@mutex = Mutex.new
49
56
  end
57
+ @@initialized = true
50
58
  end
51
59
 
52
60
  def safe_print(message = '')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediafile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Harvey-Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-19 00:00:00.000000000 Z
11
+ date: 2017-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: taglib-ruby