Skip to content

Commit

Permalink
fix: add missing permissions for save files
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-pages committed Nov 22, 2023
1 parent cb9d1b3 commit 9c409b3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sunbot/SunServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, id : int, fun : bool = False) -> None:
SunServer.srv_backup_path = "./save/srv/"
if not os.path.exists(f"{SunServer.srv_backup_path}"):
logging.info("Repertory %s doesn't exist. Creating it", SunServer.srv_backup_path)
os.makedirs(SunServer.srv_backup_path)
os.makedirs(SunServer.srv_backup_path, mode=666)

#if server was already created in the past, load data from corresponding file:
if os.path.isfile(f"{SunServer.srv_backup_path}{id}.json"):
Expand Down
2 changes: 1 addition & 1 deletion sunbot/SunUser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, id : int, emoji : str = "", freqEmoji : float = 0.5, favLocat
SunUser.usr_backup_path = "./save/usr/"
if not os.path.exists(SunUser.usr_backup_path):
logging.info("Repertory %s doesn't exist. Creating it.", SunUser.usr_backup_path)
os.makedirs(SunUser.usr_backup_path)
os.makedirs(SunUser.usr_backup_path, mode=666)

# If this user was already created by the past, load its data from the corresponding
# file instead of values passed in arguments of the constructor:
Expand Down
2 changes: 2 additions & 0 deletions sunbot/weather_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from datetime import datetime
import json
import logging
import os
from typing import Dict, Literal, Union

import discord
Expand Down Expand Up @@ -224,6 +225,7 @@ async def save_locations_subscribers(self) -> None:
self.__mutex_access_dict.release()
with open(self.save_file_path, 'w', encoding='UTF-8') as json_file:
json.dump(copy_dict, json_file, ensure_ascii=False, indent=2)
os.chmod(self.save_file_path, mode=666)
logging.info("Location's subscribers data saved into %s", self.save_file_path)

async def load_locations_subscribers(self, usr_loader, srv_loader) -> None:
Expand Down

0 comments on commit 9c409b3

Please sign in to comment.