mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
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:
@@ -1,7 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import posixpath
|
import posixpath
|
||||||
import string
|
import string
|
||||||
from shutil import copyfileobj
|
from pathlib import PurePath
|
||||||
|
from shutil import copyfileobj, rmtree
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
from flask import current_app, redirect, send_file
|
from flask import current_app, redirect, send_file
|
||||||
@@ -64,7 +65,8 @@ class FilesystemUploader(BaseUploader):
|
|||||||
|
|
||||||
def delete(self, filename):
|
def delete(self, filename):
|
||||||
if os.path.exists(os.path.join(self.base_path, 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 True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user