1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-01-10 13:17:58 +03:00

Merge remote-tracking branch 'github/kde_applier' into sisyphus

This commit is contained in:
Valery Sinelnikov 2023-09-15 10:18:51 +04:00
commit b0d3ab2384
2 changed files with 15 additions and 4 deletions

View File

@ -25,16 +25,19 @@ import smbc
from util.logging import log
from util.paths import file_cache_dir, UNCPath
from util.paths import file_cache_dir, file_cache_path_home, UNCPath
from util.exceptions import NotUNCPathError
class fs_file_cache:
__read_blocksize = 4096
def __init__(self, cache_name):
def __init__(self, cache_name, username = None):
self.cache_name = cache_name
self.storage_uri = file_cache_dir()
if username:
self.storage_uri = file_cache_path_home(username)
else:
self.storage_uri = file_cache_dir()
logdata = dict({'cache_file': self.storage_uri})
log('D20', logdata)
self.samba_context = smbc.Context(use_kerberos=1)

View File

@ -21,6 +21,7 @@ import pathlib
import os
from pathlib import Path
from urllib.parse import urlparse
from util.util import get_homedir
from .config import GPConfig
from .exceptions import NotUNCPathError
@ -67,12 +68,19 @@ def file_cache_dir():
Returns path pointing to gpupdate's cache directory
'''
cachedir = pathlib.Path('/var/cache/gpupdate_file_cache')
if not cachedir.exists():
cachedir.mkdir(parents=True, exist_ok=True)
return cachedir
def file_cache_path_home(username) -> str:
'''
Returns the path pointing to the gpupdate cache directory in the /home directory.
'''
cachedir = f'{get_homedir(username)}/.cache/gpupdate'
return cachedir
def local_policy_cache():
'''
Returns path to directory where lies local policy settings cache