shotwellfs 0.0.1RC0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ tmp
17
17
  Gemfile.lock
18
18
  .ruby-version
19
19
  .ruby-gemset
20
+ .idea
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rfuse', :path => "../rfuse", :git => "https://github.com/lwoggardner/rfuse.git"
4
- gem 'rfusefs', :path => "../rfusefs", :git => "https://github.com/lwoggardner/rfusefs.git"
3
+ #gem 'rfuse', :path => "../rfuse", :git => "https://github.com/lwoggardner/rfuse.git"
4
+ #gem 'rfusefs', :path => "../rfusefs", :git => "https://github.com/lwoggardner/rfusefs.git"
5
5
  # Specify your gem's dependencies in shotwellfs.gemspec
6
6
  gemspec
7
-
7
+
data/README.md CHANGED
@@ -25,6 +25,13 @@ For more advanced usage, including controlling how events are mapped to director
25
25
 
26
26
  $ shotwellfs -h
27
27
 
28
+ ## Developers
29
+
30
+ After checking out the source, run:
31
+
32
+ $ bundle install # install dependencies
33
+ $ bundle exec bin/shotwellfs -h
34
+
28
35
  ## Contributing
29
36
 
30
37
  1. Fork it
@@ -15,7 +15,7 @@ module ShotwellFS
15
15
  Available event fields - id, name, comment
16
16
  (default "%Y-%m %<name>s")
17
17
  -o photo_path=FMT strftime and sprintf format to generate path for photo files
18
- Available photo fields - id, title, comment, rating
18
+ Available photo fields - id, filename, title, comment, rating
19
19
  (default "%<id>d")
20
20
  -o video_path=FMT as above for video files. If not set, photo_path is used.
21
21
 
@@ -25,9 +25,7 @@ module ShotwellFS
25
25
 
26
26
  FuseFS.main(args,OPTIONS,OPTION_USAGE,"path/to/shotwell_dir") do |options|
27
27
  if options[:device] && File.exists?("#{options[:device]}/data/photo.db")
28
- fs = FileSystem.new(options)
29
- Signal.trap("HUP") { fs.rescan() }
30
- fs
28
+ FileSystem.new(options)
31
29
  else
32
30
  puts "shotwellfs: failed to access Shotwell photo database #{options[:device]}/data/photo.db"
33
31
  nil
@@ -25,13 +25,13 @@ module ShotwellFS
25
25
 
26
26
  SHOTWELL_SQL = <<-SQL
27
27
  SELECT P.rating as 'rating', P.exposure_time as 'exposure_time',
28
- P.title as 'title', P.comment as 'comment', P.filename as 'filename', P.id as 'id',
28
+ P.title as 'title', P.comment as 'comment', P.filename as 'filepath', P.id as 'id',
29
29
  P.event_id as 'event_id', "photo" as 'type', P.transformations as 'transformations'
30
30
  FROM phototable P
31
31
  WHERE P.rating >= %1$d and P.event_id > 0
32
32
  UNION
33
33
  SELECT V.rating, V.exposure_time as 'exposure_time',
34
- V.title, V.comment, V.filename as 'filename', V.id as 'id',
34
+ V.title, V.comment, V.filename as 'filepath', V.id as 'id',
35
35
  V.event_id as 'event_id', "video" as 'type', null
36
36
  FROM videotable V
37
37
  WHERE V.rating >= %1$d and V.event_id > 0
@@ -76,9 +76,9 @@ module ShotwellFS
76
76
  example_event = { id: 1, name: "<event name>", comment: "<event comment>", exposure_time: 0}
77
77
 
78
78
  example_photo = { id: 1000, title: "<photo title>", comment: "<photo comment>",
79
- rating:5, exposure_time: Time.now.to_i, filename: "photo.jpg", type: "photo" }
79
+ rating:5, exposure_time: Time.now.to_i, filepath: "photo.jpg", type: "photo", filename: 'photo' }
80
80
  example_video = { id: 1000, title: "<photo title>", comment: "<photo comment>",
81
- rating:5, exposure_time: Time.now.to_i, filename: "video.mp4", type: "video" }
81
+ rating:5, exposure_time: Time.now.to_i, filepath: "video.mp4", filename: "video", type: "video" }
82
82
 
83
83
  event_path = event_path(example_event)
84
84
 
@@ -99,8 +99,8 @@ module ShotwellFS
99
99
  @transforms_dir
100
100
  end
101
101
 
102
- def transform_required?(filename,transform_id)
103
- !(File.exists?(filename) && transform_id.eql?(Xattr.new(filename)[XATTR_TRANSFORM_ID]))
102
+ def transform_required?(filepath,transform_id)
103
+ !(File.exists?(filepath) && transform_id.eql?(Xattr.new(filepath)[XATTR_TRANSFORM_ID]))
104
104
  end
105
105
 
106
106
  def transform(row)
@@ -109,31 +109,33 @@ module ShotwellFS
109
109
  transformations = Transform.new(row[:transformations])
110
110
 
111
111
  transform_id = transformations.generate_id(row[:id])
112
- filename = "#{transforms_dir}/#{row[:id]}.jpg"
112
+ filepath = "#{transforms_dir}/#{row[:id]}.jpg"
113
113
 
114
114
  if transform_id
115
115
 
116
- if transform_required?(filename,transform_id)
116
+ if transform_required?(filepath,transform_id)
117
117
 
118
- puts "Generating transform for #{row[:filename]}"
119
- puts "Writing to #{filename} with id #{transform_id}"
118
+ puts "Generating transform for #{row[:filepath]}"
119
+ puts "Writing to #{filepath} with id #{transform_id}"
120
120
  puts transformations
121
121
 
122
- transformations.apply(row[:filename],filename)
122
+ transformations.apply(row[:filepath],filepath)
123
123
 
124
- xattr = Xattr.new(filename)
124
+ xattr = Xattr.new(filepath)
125
125
  xattr[XATTR_TRANSFORM_ID] = transform_id
126
126
  end
127
127
 
128
- return [ transform_id, filename ]
128
+ return [ transform_id, filepath ]
129
129
  end
130
130
  end
131
131
  # Ho transforms
132
- [ row[:id],row[:filename] ]
132
+ [ row[:id],row[:filepath] ]
133
133
  end
134
134
 
135
135
  def map_row(row)
136
136
  row = symbolize(row)
137
+ row[:filename] = File.basename(row[:filepath],'.*')
138
+
137
139
  xattr = file_xattr(row)
138
140
 
139
141
  transform_id, real_file = transform(row)
@@ -159,6 +161,7 @@ module ShotwellFS
159
161
 
160
162
  puts "Scan ##{scan_id} Finding images and photos for #{@events.size} events"
161
163
  super
164
+ puts "Scan ##{scan_id} complete"
162
165
  @keywords= nil
163
166
  @events = nil
164
167
  end
@@ -189,6 +192,9 @@ module ShotwellFS
189
192
  super
190
193
  end
191
194
 
195
+ def sighup()
196
+ rescan
197
+ end
192
198
 
193
199
  private
194
200
 
@@ -209,13 +215,13 @@ module ShotwellFS
209
215
  end
210
216
 
211
217
  def file_path(event_path,image)
212
- ext = File.extname(image[:filename]).downcase
218
+ ext = File.extname(image[:filepath]).downcase
213
219
 
214
220
  format = image['type'] == 'photo' ? @photo_path : @video_path
215
221
 
216
- filename = sprintf(Time.at(image[:exposure_time]).strftime(format),image)
222
+ filepath = sprintf(Time.at(image[:exposure_time]).strftime(format),image)
217
223
 
218
- return "#{event_path}/#{filename}#{ext}"
224
+ return "#{event_path}/#{filepath}#{ext}"
219
225
  end
220
226
 
221
227
  def file_xattr(image)
@@ -1,3 +1,3 @@
1
1
  module ShotwellFS
2
- VERSION = "0.0.1RC0"
2
+ VERSION = "0.0.1"
3
3
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_runtime_dependency("sqlite3","~>1.3")
21
- gem.add_runtime_dependency("rfusefs",">=1.0.2")
21
+ gem.add_runtime_dependency("rfusefs",">=1.0.3")
22
22
  gem.add_runtime_dependency("rb-inotify","~>0.9")
23
23
  gem.add_runtime_dependency("rmagick","~>2.13")
24
24
  gem.add_runtime_dependency("iniparse","~>1.1")
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shotwellfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1RC0
5
- prerelease: 5
4
+ version: 0.0.1
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Grant Gardner
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-20 00:00:00.000000000 Z
12
+ date: 2015-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 1.0.2
37
+ version: 1.0.3
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 1.0.2
45
+ version: 1.0.3
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rb-inotify
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -189,9 +189,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
189
  required_rubygems_version: !ruby/object:Gem::Requirement
190
190
  none: false
191
191
  requirements:
192
- - - ! '>'
192
+ - - ! '>='
193
193
  - !ruby/object:Gem::Version
194
- version: 1.3.1
194
+ version: '0'
195
195
  requirements: []
196
196
  rubyforge_project:
197
197
  rubygems_version: 1.8.25