Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion conan/internal/model/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import hashlib
import numbers
import platform
import re
Expand Down Expand Up @@ -756,7 +757,8 @@ def load_global_conf(home_folder):
content = template.render({"platform": platform, "os": os, "distro": distro,
"conan_version": conan_version,
"conan_home_folder": home_folder,
"detect_api": detect_api})
"detect_api": detect_api,
"hashlib": hashlib})
new_config.loads(content)
else: # creation of a blank global.conf file for user convenience
default_global_conf = textwrap.dedent("""\
Expand Down
17 changes: 17 additions & 0 deletions test/integration/cache/storage_path_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
import textwrap
from hashlib import sha256

from conan.test.utils.test_files import temp_folder
from conan.test.utils.tools import TestClient, GenConanfile
Expand All @@ -22,3 +24,18 @@ def test_wrong_home_error():
client.save_home({"global.conf": "core.cache:storage_path=//"})
client.run("list *")
assert "Couldn't initialize storage in" in client.out


def test_short_storage_path():
c = TestClient()
global_conf = textwrap.dedent("""\
{% set h = hashlib.new("sha256", conan_home_folder.encode(),
usedforsecurity=False).hexdigest() %}
core.cache:storage_path=C:/conan_{{h[:6]}}
""")
c.save_home({"global.conf": global_conf})
c.run("config show *")
myhash = sha256()
myhash.update(c.cache_folder.replace("\\", "/").encode())
myhash = myhash.hexdigest()[:6]
assert f"core.cache:storage_path: C:/conan_{myhash}" in c.out
Loading