Fixed issue of system exiting during active session
When the entire OS halts during the middle of a pappy crypto session, the `crypt` working directory is left unencrypted. To fix this, I added another conditional into `crypto.py`'s decryption function to enter an existing crypto working directory, so that when the project finishes it will encrypt/exit properly.
This commit is contained in:
parent
772e7ee507
commit
587cf75058
1 changed files with 18 additions and 13 deletions
|
@ -61,19 +61,8 @@ class Crypto(object):
|
||||||
Decrypt and decompress the project files
|
Decrypt and decompress the project files
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# If project hasn't been encrypted before,
|
# Decrypt and decompress the project if crypt_file exists
|
||||||
# setup crypt working directory
|
if os.path.isfile(self.config.crypt_file):
|
||||||
if not os.path.isfile(self.config.crypt_file):
|
|
||||||
os.mkdir(self.config.crypt_dir)
|
|
||||||
|
|
||||||
project_files = self.config.get_project_files()
|
|
||||||
for pf in project_files:
|
|
||||||
shutil.copy2(pf, self.config.crypt_dir)
|
|
||||||
os.chdir(self.config.crypt_dir)
|
|
||||||
return True
|
|
||||||
|
|
||||||
# Otherwise, decrypt and decompress the project
|
|
||||||
else:
|
|
||||||
archive_crypt = open(self.config.crypt_file, 'rb').read()
|
archive_crypt = open(self.config.crypt_file, 'rb').read()
|
||||||
archive_file = open(self.config.archive, 'wb')
|
archive_file = open(self.config.archive, 'wb')
|
||||||
|
|
||||||
|
@ -109,6 +98,22 @@ class Crypto(object):
|
||||||
os.chdir(self.config.crypt_dir)
|
os.chdir(self.config.crypt_dir)
|
||||||
self.config.crypt_success = True
|
self.config.crypt_success = True
|
||||||
return True
|
return True
|
||||||
|
# If project exited before encrypting the working directory
|
||||||
|
# change to the working directory to resume the session
|
||||||
|
elif os.path.isdir(self.config.crypt_dir):
|
||||||
|
os.chdir(self.config.crypt_dir)
|
||||||
|
return True
|
||||||
|
# If project hasn't been encrypted before,
|
||||||
|
# setup crypt working directory
|
||||||
|
else:
|
||||||
|
os.mkdir(self.config.crypt_dir)
|
||||||
|
|
||||||
|
project_files = self.config.get_project_files()
|
||||||
|
for pf in project_files:
|
||||||
|
shutil.copy2(pf, self.config.crypt_dir)
|
||||||
|
os.chdir(self.config.crypt_dir)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def confirm_password_retry(self):
|
def confirm_password_retry(self):
|
||||||
answer = raw_input("Re-enter your password? (y/n)").strip()
|
answer = raw_input("Re-enter your password? (y/n)").strip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue