Skip to content

Commit

Permalink
MDL-66004 Fix delete_dir for server-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllaó committed Oct 3, 2019
1 parent 531ca79 commit 38c4ef4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion moodlemlbackend/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.2.1
7 changes: 4 additions & 3 deletions moodlemlbackend/webapp/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ def get_model_dir(self, hashkey, fetch_model=False):

def delete_dir(self):

s3 = boto3.client('s3')
s3 = boto3.resource('s3')

bucketname = os.environ["MOODLE_MLBACKEND_PYTHON_S3_BUCKET_NAME"]
bucket = s3.Bucket(bucketname)

# Objectkey will equal uniquemodelid so we delete all files matching
# uniquemodelid/ namespace.
objectkey = self.object_key(False)
for key in s3.listobjects(Bucket=bucketname, Prefix=objectkey + '/'):
key.delete()

bucket.objects.filter(Prefix=objectkey + '/').delete()

def object_key(self, hashkey=False):

Expand Down
2 changes: 1 addition & 1 deletion webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def import_model():
@setup_base_dir(storage, False, False)
def deletemodel():
# All processing is delegated to delete_dir as it is file system dependant.
storage.delete_dir
storage.delete_dir()
return 'Ok', 200


Expand Down

0 comments on commit 38c4ef4

Please sign in to comment.