Skip to content

Commit

Permalink
Add hack
Browse files Browse the repository at this point in the history
  • Loading branch information
anayden committed May 7, 2019
1 parent f51a58e commit 4af47c3
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions platform_storage_api/fs/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass, replace
from pathlib import Path, PurePath
from typing import Any, List, Optional
from typing import TYPE_CHECKING, Any, List, Optional

import aiofiles

Expand Down Expand Up @@ -208,18 +208,33 @@ def _remove(self, path: PurePath) -> None:
else:
concrete_path.unlink()

def _handle_rmtree_error(
self, func: Any, path: os.PathLike[str], exc_info: Any
) -> Any:
logger.warning("Handling Error for file %s", path)
logger.warning(exc_info)
# Check if file access issue
if not os.access(path, os.W_OK):
logger.warning("Access error")
# Try to change the permission of file
os.chmod(path, stat.S_IWUSR)
# call the calling function again
func(path)
if TYPE_CHECKING:

def _handle_rmtree_error(
self, func: Any, path: os.PathLike[str], exc_info: Any
) -> Any:
logger.warning("Handling Error for file %s", path)
logger.warning(exc_info)
# Check if file access issue
if not os.access(path, os.W_OK):
logger.warning("Access error")
# Try to change the permission of file
os.chmod(path, stat.S_IWUSR)
# call the calling function again
func(path)

else:

def _handle_rmtree_error(self, func, path, exc_info) -> Any:
logger.warning("Handling Error for file %s", path)
logger.warning(exc_info)
# Check if file access issue
if not os.access(path, os.W_OK):
logger.warning("Access error")
# Try to change the permission of file
os.chmod(path, stat.S_IWUSR)
# call the calling function again
func(path)

async def remove(self, path: PurePath) -> None:
await self._loop.run_in_executor(self._executor, self._remove, path)
Expand Down

0 comments on commit 4af47c3

Please sign in to comment.