Skip to content

Commit

Permalink
First attempt at handling a local destination directory that already …
Browse files Browse the repository at this point in the history
…exists.
  • Loading branch information
dvjones89 committed May 21, 2018
1 parent 478b2be commit 95f842b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/sheldon/brain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ def recall(recall_cue)
entry = memory.recall(recall_cue)
destination_path = add_home(entry[:filepath])
destination_dir = File.dirname(destination_path)
raise DestinationNotEmptyException, "#{destination_path} is not empty." if File.exist?(destination_path)

FileUtils.mkdir_p(destination_dir) unless File.directory?(destination_dir)
brain_path = brain_path_for_cue(recall_cue)
FileUtils.ln_s(get_content(brain_path), destination_path, force: true)
FileUtils.ln_s(get_content(brain_path), destination_path)
return true
end

Expand Down
3 changes: 3 additions & 0 deletions lib/sheldon/exceptions.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class MissingDataDirectoryException < StandardError
end

class DestinationNotEmptyException < StandardError
end

0 comments on commit 95f842b

Please sign in to comment.