incremental_backup 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/incremental_backup/lock.rb +3 -4
- data/lib/incremental_backup/version.rb +1 -1
- data/spec/unit/lock_spec.rb +36 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55816485677ef959a89ab2b21baaae7d5f253c06
|
4
|
+
data.tar.gz: 65f9e303fd3ad201d4dfd146581c86e275bdea95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87c946b7933ad50fc901d1b61623eef3e5659239fdc71173ba35bff18a5bb0c7d2e2f46c268cdba1a06599831807220fff38b798796403f2fe8dc46a320807d
|
7
|
+
data.tar.gz: f037901df777dd755a40e40233d345732173c4901314df66fc5d7b27527fc638e4064732d06069fcce89fa9c7c9dd9348f4f6fd0d6f1cfbb5d7923255eb5236a
|
@@ -11,10 +11,9 @@ module IncrementalBackup
|
|
11
11
|
def initialize task
|
12
12
|
@task = task
|
13
13
|
|
14
|
-
|
14
|
+
@lock_file = File.open(path, File::RDWR|File::CREAT, 0644)
|
15
|
+
unless @lock_file.flock(File::LOCK_EX|File::LOCK_NB)
|
15
16
|
self.failed = true
|
16
|
-
else
|
17
|
-
FileUtils.touch path
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
@@ -44,7 +43,7 @@ module IncrementalBackup
|
|
44
43
|
|
45
44
|
# Release lock
|
46
45
|
def release
|
47
|
-
|
46
|
+
@lock_file.close if @lock_file
|
48
47
|
end
|
49
48
|
|
50
49
|
private
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe IncrementalBackup::Lock do
|
4
|
+
|
5
|
+
# Mocks
|
6
|
+
let(:task) { double("task", logger: logger, settings: settings) }
|
7
|
+
let(:logger) { double("logger", info: nil) }
|
8
|
+
let(:settings) { double("settings", settings_path: settings_path, task_id: task_id) }
|
9
|
+
|
10
|
+
# Settings
|
11
|
+
let(:settings_path) { File.join __dir__, "..", "tmp" }
|
12
|
+
let(:task_id) { "example_task" }
|
13
|
+
|
14
|
+
|
15
|
+
it 'can run' do
|
16
|
+
ran = false
|
17
|
+
IncrementalBackup::Lock.create task do
|
18
|
+
ran = true
|
19
|
+
end
|
20
|
+
ran.should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can lock' do
|
24
|
+
ran_outer = false
|
25
|
+
ran_inner = false
|
26
|
+
|
27
|
+
IncrementalBackup::Lock.create task do
|
28
|
+
ran_outer = true
|
29
|
+
IncrementalBackup::Lock.create task do
|
30
|
+
ran_inner = true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
ran_outer.should be_true
|
34
|
+
ran_inner.should be_false
|
35
|
+
end
|
36
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: incremental_backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Skindstad Ebert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- live_example/example_task.rb
|
134
134
|
- live_example/exclude.file
|
135
135
|
- spec/spec_helper.rb
|
136
|
+
- spec/unit/lock_spec.rb
|
136
137
|
- spec/unit/task_settings_spec.rb
|
137
138
|
- spec/unit/task_spec.rb
|
138
139
|
- spec/unit/version_spec.rb
|
@@ -162,6 +163,7 @@ summary: incremental_backup can make incremental backups by hour/day/week/month/
|
|
162
163
|
remotely through ssh and rsync
|
163
164
|
test_files:
|
164
165
|
- spec/spec_helper.rb
|
166
|
+
- spec/unit/lock_spec.rb
|
165
167
|
- spec/unit/task_settings_spec.rb
|
166
168
|
- spec/unit/task_spec.rb
|
167
169
|
- spec/unit/version_spec.rb
|