This commit is contained in:
usman@cyberpersons.com
2023-08-14 17:51:04 +05:00
parent c3a6fa7f6e
commit cd983140ae

View File

@@ -1141,29 +1141,12 @@ team_drive =
@staticmethod
def DeleteRepoScheduleV2(website, repo, eu):
import shutil
try:
finalConfigPath = f'/home/{website}/.config/rclone/rclone.conf'
if os.path.exists(finalConfigPath):
command = f'cat {finalConfigPath}'
result = ProcessUtilities.outputExecutioner(command, eu)
new_lines = []
skip_section = False
for line in result.split('\n'):
if line.strip().startswith('[') and line.strip().endswith(']'):
if line.strip() == f'[{repo}]':
skip_section = True
else:
skip_section = False
if not skip_section:
new_lines.append(line)
cmd = f'echo "{new_lines}" > {finalConfigPath}'
result = ProcessUtilities.outputExecutioner(cmd, eu, True)
command = f"sed -i '/\[{repo}\]/,/^$/d' {finalConfigPath}"
ProcessUtilities.outputExecutioner(command, eu, True)
return 1, 'Done'