semmyk commited on
Commit
1e8cc4d
·
1 Parent(s): aab6bfe

fix: if file exists - dir_path.mkdir(parents=True, exist_ok=True, mode=0o2664) #, mode=0o2644)

Browse files
Files changed (1) hide show
  1. file_handler/file_utils.py +3 -2
file_handler/file_utils.py CHANGED
@@ -45,10 +45,11 @@ def check_create_file(filename: str, dir_path: Union[str, Path]="logs") -> Path:
45
  # Create the parent directory if it doesn't exist.
46
  # `parents=True` creates any missing parent directories.
47
  # `exist_ok=True` prevents an error if the directory already exists.
48
- dir_path.mkdir(parents=True, exist_ok=True) #, mode=0o2644)
 
49
 
50
  file_path = dir_path / filename # Concatenate directory and filename to get full path
51
- if not file_path.exists(): # Create the file if it doesn't exist
52
  file_path.touch() # Creates an empty file if it doesn't exists
53
  #file_dir.touch(mode=0o2644, exist_ok=True) #, parents=True) ##SMY: Note Permission Errno13 - https://stackoverflow.com/a/57454275
54
  #file_dir.chmod(0)
 
45
  # Create the parent directory if it doesn't exist.
46
  # `parents=True` creates any missing parent directories.
47
  # `exist_ok=True` prevents an error if the directory already exists.
48
+ dir_path.mkdir(parents=True, exist_ok=True, mode=0o2664) #, mode=0o2644)
49
+ file_dir.chmod(0)
50
 
51
  file_path = dir_path / filename # Concatenate directory and filename to get full path
52
+ if not file_path.exists(): # check if file doesn't exist
53
  file_path.touch() # Creates an empty file if it doesn't exists
54
  #file_dir.touch(mode=0o2644, exist_ok=True) #, parents=True) ##SMY: Note Permission Errno13 - https://stackoverflow.com/a/57454275
55
  #file_dir.chmod(0)