Skip to content

Commit

Permalink
fix issue leonidessaguisagjr#10: Evaluate file paths from checksum di…
Browse files Browse the repository at this point in the history
…r II
  • Loading branch information
mattalxndr committed Dec 4, 2021
1 parent 2cf0f30 commit b8a4f47
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions filehash/filehash.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,9 @@ def hash_dir(self, path, pattern='*'):
:returns: List of tuples where each tuple contains a filename and the
calculated hash for each file.
"""
saved_dir = os.getcwd()
os.chdir(os.path.abspath(path)) # pushd
filenames = [filename for filename in glob.glob(pattern) if os.path.isfile(filename)]
result = self.hash_files(filenames)
os.chdir(saved_dir) # popd
with _chdir(os.path.abspath(path)):
filenames = [filename for filename in glob.glob(pattern) if os.path.isfile(filename)]
result = self.hash_files(filenames)
return result

def cathash_files(self, filenames):
Expand Down Expand Up @@ -237,11 +235,9 @@ def cathash_dir(self, path, pattern='*'):
Defaults to '*' i.e. all files in the directory.
:returns: Digest of the files, in hex.
"""
saved_dir = os.getcwd()
os.chdir(os.path.abspath(path)) # pushd
filenames = [filename for filename in glob.glob(pattern) if os.path.isfile(filename)]
result = self.cathash_files(filenames)
os.chdir(saved_dir) # popd
with _chdir(os.path.abspath(path)):
filenames = [filename for filename in glob.glob(pattern) if os.path.isfile(filename)]
result = self.cathash_files(filenames)
return result

def verify_checksums(self, checksum_filename):
Expand Down

0 comments on commit b8a4f47

Please sign in to comment.