Skip to content

Commit 38eb39d

Browse files
committed
show more errors
1 parent 89747db commit 38eb39d

File tree

2 files changed

+40
-24
lines changed

2 files changed

+40
-24
lines changed

bin/rbphoto-import

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ class RbPhoto
4646

4747
def initialize
4848
@args = RbPhoto::Args.new
49-
@fileopts = {:force => @args['force'],
50-
:verbose => @args['verbose'],
49+
@fileopts = {:verbose => @args['verbose'],
5150
:noop => @args['no_act']}
5251
@postfix = '-' + ENV['USER']
5352
if ( @args['version'] )
@@ -77,27 +76,43 @@ class RbPhoto
7776

7877
def copy
7978
@target.each do |file|
80-
if ( @args['without_rename'] )
81-
target_file = file
82-
else
83-
target_file = self.rename(file)
84-
end
85-
86-
target_dir = File.dirname(target_file)
87-
if ( ! File.directory?(target_dir) )
88-
FileUtils.makedirs(target_dir, @fileopts)
89-
end
90-
91-
begin
92-
if ( @args['move'] )
93-
FileUtils.mv(file, target_file, @fileopts)
94-
else
95-
FileUtils.cp(file, target_file, @fileopts)
96-
end
97-
FileUtils.chmod(0444, target_file, @fileopts)
98-
rescue => e
99-
STDERR.puts "ERROR: execution failed: #{e.to_s}"
100-
end
79+
if ( @args['without_rename'] )
80+
target_file = file
81+
else
82+
target_file = self.rename(file)
83+
end
84+
85+
target_dir = File.dirname(target_file)
86+
if ( ! File.directory?(target_dir) )
87+
begin
88+
FileUtils.makedirs(target_dir, @fileopts)
89+
rescue => e
90+
STDERR.puts "ERROR: mkdir failed: #{e.to_s}"
91+
end
92+
end
93+
94+
if ( @args['move'] )
95+
begin
96+
FileUtils.mv(file, target_file, @fileopts)
97+
rescue => e
98+
if ( e.is_a?(Errno::EACCES) && @args['force'] && !File.writable?(target_file))
99+
FileUtils.chmod(0644, target_file, @fileopts)
100+
retry
101+
end
102+
STDERR.puts "ERROR: mv failed: #{e.to_s}"
103+
end
104+
else
105+
begin
106+
FileUtils.cp(file, target_file, @fileopts)
107+
rescue => e
108+
STDERR.puts "ERROR: cp failed: #{e.to_s}"
109+
end
110+
end
111+
begin
112+
FileUtils.chmod(0444, target_file, @fileopts)
113+
rescue => e
114+
STDERR.puts "ERROR: chmod failed: #{e.to_s}"
115+
end
101116
end
102117
end
103118

debian/changelog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ rbphoto (0.1.4) unstable; urgency=low
33
* Use "fileutils" instead of "ftools"
44
- Use fileutils feature to show verbose output
55
* Add "--force" option to overwrite when the file exists
6+
* Show more errors
67

7-
-- Taku YASUI <[email protected]> Thu, 19 Jun 2008 02:42:49 +0900
8+
-- Taku YASUI <[email protected]> Thu, 19 Jun 2008 04:25:08 +0900
89

910
rbphoto (0.1.3) unstable; urgency=low
1011

0 commit comments

Comments
 (0)