import shutil
import os
from storage.storage import BaseStorage
import logging
logger = logging.getLogger(__name__)


class LocalStorage(BaseStorage):

    TYPE = 'fs'

    def file_exists(self, filepath):
        return os.path.exists(filepath) and os.path.isfile(filepath)

    def directory_exists(self, filepath):
        return os.path.exists(filepath) and os.path.isdir(filepath)

    def _make_folder_action(self, path):
        os.makedirs(path)
        return True

    def _upload_file_action(self, source, destination):
        shutil.copy(source, destination)
        return True

    def _download_file_action(self, source, destination):
        shutil.copy(source, destination)
        return True