Skip to content
This repository has been archived by the owner on Jun 7, 2023. It is now read-only.

Commit

Permalink
Abort tag addition or deletion if the file is not stored (closes: #273)
Browse files Browse the repository at this point in the history
  • Loading branch information
botherder committed Apr 4, 2015
1 parent beae3d0 commit 1d4273f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions viper/core/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,15 @@ def cmd_tags(self, *args):

# TODO: handle situation where addition or deletion of a tag fail.

db = Database()
if not db.find(key='sha256', value=__sessions__.current.file.sha256):
self.log('error', "The opened file is not stored in the database. "
"If you want to add it use the `store` command.")
return

if args.add:
# Add specified tags to the database's entry belonging to
# the opened file.
db = Database()
db.add_tags(__sessions__.current.file.sha256, args.add)
self.log('info', "Tags added to the currently opened file")

Expand All @@ -572,7 +577,7 @@ def cmd_tags(self, *args):

if args.delete:
# Delete the tag from the database.
Database().delete_tag(args.delete, __sessions__.current.file.sha256)
db.delete_tag(args.delete, __sessions__.current.file.sha256)
# Refresh the session so that the attributes of the file are
# updated.
self.log('info', "Refreshing session to update attributes...")
Expand Down

0 comments on commit 1d4273f

Please sign in to comment.