Confirmed REST API does delete directories in s3 bucket. The local filesystem didn't though and that was updated. Closes #1758 (#1876)

- Deleting uploads under the Filesystem upload provider will now delete the parent folder as well as the target file
- Closes #1758
This commit is contained in:
Ife Lawal
2021-06-06 23:21:38 -04:00
committed by GitHub
parent 1195454258
commit c31916057f

View File

@@ -1,7 +1,8 @@
import os
import posixpath
import string
from shutil import copyfileobj
from pathlib import PurePath
from shutil import copyfileobj, rmtree
import boto3
from flask import current_app, redirect, send_file
@@ -64,7 +65,8 @@ class FilesystemUploader(BaseUploader):
def delete(self, filename):
if os.path.exists(os.path.join(self.base_path, filename)):
os.unlink(os.path.join(self.base_path, filename))
file_path = PurePath(filename).parts[0]
rmtree(os.path.join(self.base_path, file_path))
return True
return False