mirror of https://github.com/zulip/zulip.git
provision: Extract path_version_digest().
This commit is contained in:
parent
2bd836bc4c
commit
b280f73c77
|
@ -379,11 +379,8 @@ def os_families() -> Set[str]:
|
||||||
distro_info = parse_os_release()
|
distro_info = parse_os_release()
|
||||||
return {distro_info["ID"], *distro_info.get("ID_LIKE", "").split()}
|
return {distro_info["ID"], *distro_info.get("ID_LIKE", "").split()}
|
||||||
|
|
||||||
def file_or_package_hash_updated(hash_name: str,
|
def path_version_digest(paths: List[str],
|
||||||
paths: List[str],
|
package_versions: List[str]) -> str:
|
||||||
package_versions: List[str]=[]) -> bool:
|
|
||||||
# Check whether the files or package_versions passed as arguments
|
|
||||||
# changed compared to the last execution.
|
|
||||||
sha1sum = hashlib.sha1()
|
sha1sum = hashlib.sha1()
|
||||||
for path in paths:
|
for path in paths:
|
||||||
with open(path, 'rb') as file_to_hash:
|
with open(path, 'rb') as file_to_hash:
|
||||||
|
@ -394,8 +391,16 @@ def file_or_package_hash_updated(hash_name: str,
|
||||||
for package_version in package_versions:
|
for package_version in package_versions:
|
||||||
sha1sum.update(package_version.encode("utf-8"))
|
sha1sum.update(package_version.encode("utf-8"))
|
||||||
|
|
||||||
|
return sha1sum.hexdigest()
|
||||||
|
|
||||||
|
def file_or_package_hash_updated(hash_name: str,
|
||||||
|
paths: List[str],
|
||||||
|
package_versions: List[str]=[]) -> bool:
|
||||||
|
# Check whether the files or package_versions passed as arguments
|
||||||
|
# changed compared to the last execution.
|
||||||
hash_path = os.path.join(get_dev_uuid_var_path(), hash_name)
|
hash_path = os.path.join(get_dev_uuid_var_path(), hash_name)
|
||||||
new_hash = sha1sum.hexdigest()
|
new_hash = path_version_digest(paths, package_versions)
|
||||||
|
|
||||||
with open(hash_path, 'a+') as hash_file:
|
with open(hash_path, 'a+') as hash_file:
|
||||||
hash_file.seek(0)
|
hash_file.seek(0)
|
||||||
last_hash = hash_file.read()
|
last_hash = hash_file.read()
|
||||||
|
|
Loading…
Reference in New Issue