Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete files for removed issues #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/jirasync/local_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ def initialize(path)

def save(issue)
json = JSON.pretty_generate(issue)
file_path = "#{@path}/#{issue['key']}.json"
file_path = issue_path(issue['key'])
File.write(file_path, json)

updateTime = DateTime.parse(issue['fields']['updated'])

File.utime(DateTime.now.to_time, updateTime.to_time, file_path)
end

def remove(key)
path = issue_path(key)
FileUtils.rm_f(path)
end

def issue_path(key)
"#{@path}/#{key}.json"
end

def state_exists?
file_path = "#{@path}/sync_state.json"
File.exist?(file_path)
Expand Down Expand Up @@ -47,4 +56,4 @@ def save_attachment(issue, attachment, data)
File.write(file_path, data, {:mode => 'wb'})
end
end
end
end
5 changes: 2 additions & 3 deletions lib/jirasync/syncer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fetch(keys)
if (e.status != 404)
keys_with_errors.push(key)
else
# Ticket has disappeared
@repo.remove(key)
end
rescue => e
STDERR.puts(e.to_s)
Expand Down Expand Up @@ -83,7 +83,6 @@ def update()

def dump()
puts(@latest_issue_key)

end
end
end
end
2 changes: 1 addition & 1 deletion lib/jirasync/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module JiraSync
VERSION = "0.4.6"
VERSION = "0.4.7"
end