[Core Commands] Add patch for invalid path with [p]backup (#2626)

* Add patch
This commit is contained in:
Neuro Assassin 2019-04-29 19:38:36 -04:00 committed by Michael H
parent c1bee3fee5
commit c79b5e6179

View File

@ -6,6 +6,7 @@ import itertools
import json import json
import logging import logging
import os import os
import pathlib
import sys import sys
import tarfile import tarfile
import traceback import traceback
@ -1166,6 +1167,12 @@ class Core(commands.Cog, CoreLogic):
@checks.is_owner() @checks.is_owner()
async def backup(self, ctx: commands.Context, *, backup_path: str = None): async def backup(self, ctx: commands.Context, *, backup_path: str = None):
"""Creates a backup of all data for the instance.""" """Creates a backup of all data for the instance."""
if backup_path:
path = pathlib.Path(backup_path)
if not (path.exists() and path.is_dir()):
return await ctx.send(
_("That path doesn't seem to exist. Please provide a valid path.")
)
from redbot.core.data_manager import basic_config, instance_name from redbot.core.data_manager import basic_config, instance_name
from redbot.core.drivers.red_json import JSON from redbot.core.drivers.red_json import JSON