summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2014-07-26 11:10:46 +0200
committerChris Schlaeger <chris@linux.com>2014-07-26 11:10:46 +0200
commita58dceffc680b5005ae3e1d53fb4bb8aa340026c (patch)
tree258f574376b47a5bc33e06b63e3bd38db03c6e5f
parent4438965dd6282710d34862983f0ec549371e744a (diff)
downloadpostrunner-a58dceffc680b5005ae3e1d53fb4bb8aa340026c.zip
Ensure that all directories are created if they not yet exist.
-rw-r--r--lib/postrunner/ActivitiesDB.rb6
-rw-r--r--lib/postrunner/Main.rb1
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/postrunner/ActivitiesDB.rb b/lib/postrunner/ActivitiesDB.rb
index 17e1760..c6fbc3f 100644
--- a/lib/postrunner/ActivitiesDB.rb
+++ b/lib/postrunner/ActivitiesDB.rb
@@ -15,6 +15,7 @@ module PostRunner
@fit_dir = File.join(@db_dir, 'fit')
@archive_file = File.join(@db_dir, 'archive.yml')
+ create_directories
if Dir.exists?(@db_dir)
begin
if File.exists?(@archive_file)
@@ -26,7 +27,6 @@ module PostRunner
Log.fatal "Cannot load archive file '#{@archive_file}': #{$!}"
end
else
- create_directories
@activities = []
end
@@ -42,7 +42,7 @@ module PostRunner
return false
end
- if File.exists(File.join(@fit_dir, base_fit_file))
+ if File.exists?(File.join(@fit_dir, base_fit_file))
Log.debug "Activity #{fit_file} has been deleted before"
return false
end
@@ -145,6 +145,8 @@ module PostRunner
end
def create_directory(dir, name)
+ return if Dir.exists?(dir)
+
Log.info "Creating #{name} directory #{dir}"
begin
Dir.mkdir(dir)
diff --git a/lib/postrunner/Main.rb b/lib/postrunner/Main.rb
index 5187011..f32fca4 100644
--- a/lib/postrunner/Main.rb
+++ b/lib/postrunner/Main.rb
@@ -11,6 +11,7 @@ module PostRunner
Log.formatter = proc { |severity, datetime, progname, msg|
"#{severity == Logger::INFO ? '' : "#{severity}:"} #{msg}\n"
}
+ Log.level = Logger::INFO
class Main