Extract file utils

This commit is contained in:
jonct 2024-07-15 01:54:39 -04:00
parent 673e77e003
commit 3a833923c0
No known key found for this signature in database
2 changed files with 15 additions and 6 deletions

View File

@ -707,12 +707,7 @@ def run_lxc_download_script(
return 0
def stat_chmod(file_path, mode):
"""
Change mode if file doesn't already have this mode.
"""
if mode != stat.S_IMODE(os.stat(file_path).st_mode):
os.chmod(file_path, mode)
from utils.files import stat_chmod
def get_mount_point(path):

14
src/jlmkr/utils/files.py Normal file
View File

@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers <https://github.com/Jip-Hop/jailmaker>
#
# SPDX-License-Identifier: LGPL-3.0-only
import os
import stat
def stat_chmod(file_path, mode):
"""
Change mode if file doesn't already have this mode.
"""
if mode != stat.S_IMODE(os.stat(file_path).st_mode):
os.chmod(file_path, mode)