From 9f03658f84692f910d2293f8891fedeb878f4063 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Tue, 30 Nov 2021 13:24:09 -0500 Subject: [PATCH 1/9] Updated copy to ensure that it returns as described in the stagger docs Signed-off-by: Alexandra Drazilov --- mock/.idea/workspace.xml | 36 +++++++++++++++++++++++++++++++++ mock/server.py | 43 ++++++++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 mock/.idea/workspace.xml diff --git a/mock/.idea/workspace.xml b/mock/.idea/workspace.xml new file mode 100644 index 000000000..4c56b7bfe --- /dev/null +++ b/mock/.idea/workspace.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + 1638241863737 + + + + \ No newline at end of file diff --git a/mock/server.py b/mock/server.py index d2a3f212b..596b5c4ba 100644 --- a/mock/server.py +++ b/mock/server.py @@ -519,22 +519,39 @@ def unixfile_rename(subpath): return {"msg": "File Successfully Renamed"} +#TODO: Add in created time +#TODO: Add in parent and active directory support @app.route('/unixfile/copy/', methods=['POST']) def unixfile_copy(subpath): + #Fix contents problemo if request.method == 'POST': - newNames = request.get_json()['newName'].split('/') - paths = subpath.split('/') directory = global_directory - for i in range(len(paths)-1): - directory = directory["contents"][paths[i]] - newDirectory = directory['contents'][paths[len(paths)-1]].copy() - dir = global_directory - for i in range(len(newNames)): - if i == len(newNames)-1: - dir['contents'][newNames[i]] = newDirectory - dir = dir["contents"][newNames[i]] - return {"msg": "File Successfully Copied"} + newName = request.args.get('newName') + if(newName is None or newName is ""): + return {"msg": "newName query parameter is missing."}, 400 + newNames = newName.split("/") + currPath = directory["contents"] + overwrite = request.args.get('forceOverwrite') + if(overwrite is None or overwrite.lower() == "false"): + overwrite = False + else: + overwrite = True + #Get to one above the path of the destination the copy goes to + for x in range(0, len(newNames)-1): + if(newNames[x] not in currPath): + currPath[newNames[x]] = {"contents": {}} + currPath = currPath[newNames[x]]["contents"] + subpath = subpath.split("/") + #Get directory/file that to be copied while also checking if it even exists + for x in range(0, len(subpath)): + if(subpath[x] not in directory["contents"]): + return {"msg": "Directory/File not found."}, 404 + directory = directory["contents"][subpath[x]] + if(newNames[len(newNames)-1] not in currPath or overwrite): + currPath[newNames[len(newNames)-1]] = directory + else: + return{"msg": "Directory/File already exists"}, 403 + return {"msg": "Successfully copied the directory/file"}, 200 if __name__ == '__main__': - app.run(debug=True) - + app.run(debug=True) \ No newline at end of file From 6036b1538a90947dc70516115352c3a5b93d7fd1 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Tue, 30 Nov 2021 13:24:35 -0500 Subject: [PATCH 2/9] Deleted idea folder Signed-off-by: Alexandra Drazilov --- mock/.idea/workspace.xml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 mock/.idea/workspace.xml diff --git a/mock/.idea/workspace.xml b/mock/.idea/workspace.xml deleted file mode 100644 index 4c56b7bfe..000000000 --- a/mock/.idea/workspace.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - 1638241863737 - - - - \ No newline at end of file From 4d495853af553cf4272bdc18513ef8ee0b12f35f Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Mon, 6 Dec 2021 13:21:48 -0500 Subject: [PATCH 3/9] Removed stray comment Signed-off-by: Alexandra Drazilov --- mock/.idea/workspace.xml | 38 ++++++++++++++++++++++++++++++++++++++ mock/server.py | 1 - 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 mock/.idea/workspace.xml diff --git a/mock/.idea/workspace.xml b/mock/.idea/workspace.xml new file mode 100644 index 000000000..387ab4603 --- /dev/null +++ b/mock/.idea/workspace.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + 1638241863737 + + + + \ No newline at end of file diff --git a/mock/server.py b/mock/server.py index 596b5c4ba..19c4c29a1 100644 --- a/mock/server.py +++ b/mock/server.py @@ -523,7 +523,6 @@ def unixfile_rename(subpath): #TODO: Add in parent and active directory support @app.route('/unixfile/copy/', methods=['POST']) def unixfile_copy(subpath): - #Fix contents problemo if request.method == 'POST': directory = global_directory newName = request.args.get('newName') From 46e746328c135a8b9138431730a73ac5e8f169ef Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Mon, 6 Dec 2021 13:22:07 -0500 Subject: [PATCH 4/9] Removed idea folder Signed-off-by: Alexandra Drazilov --- mock/.idea/workspace.xml | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 mock/.idea/workspace.xml diff --git a/mock/.idea/workspace.xml b/mock/.idea/workspace.xml deleted file mode 100644 index 387ab4603..000000000 --- a/mock/.idea/workspace.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - 1638241863737 - - - - \ No newline at end of file From c8a6ed9488397ae5782fae1a85e40ded3b4e44d4 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Mon, 6 Dec 2021 13:25:47 -0500 Subject: [PATCH 5/9] Added back whitespace at the bottom of the file Signed-off-by: Alexandra Drazilov --- mock/.idea/workspace.xml | 37 +++++++++++++++++++++++++++++++++++++ mock/server.py | 3 ++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 mock/.idea/workspace.xml diff --git a/mock/.idea/workspace.xml b/mock/.idea/workspace.xml new file mode 100644 index 000000000..774d38ec7 --- /dev/null +++ b/mock/.idea/workspace.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + 1638241863737 + + + + \ No newline at end of file diff --git a/mock/server.py b/mock/server.py index 19c4c29a1..a0c3e646a 100644 --- a/mock/server.py +++ b/mock/server.py @@ -553,4 +553,5 @@ def unixfile_copy(subpath): return {"msg": "Successfully copied the directory/file"}, 200 if __name__ == '__main__': - app.run(debug=True) \ No newline at end of file + app.run(debug=True) + \ No newline at end of file From b40469c33bcdd6520634e12eec16094b7ba31f72 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Mon, 6 Dec 2021 13:26:15 -0500 Subject: [PATCH 6/9] Removed tab from last line Signed-off-by: Alexandra Drazilov --- mock/server.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mock/server.py b/mock/server.py index a0c3e646a..336aa8302 100644 --- a/mock/server.py +++ b/mock/server.py @@ -554,4 +554,3 @@ def unixfile_copy(subpath): if __name__ == '__main__': app.run(debug=True) - \ No newline at end of file From deb26d7bd32db7a261f95b0e378deeaa5020cdf9 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Mon, 6 Dec 2021 13:27:03 -0500 Subject: [PATCH 7/9] Removed last line Signed-off-by: Alexandra Drazilov --- mock/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock/server.py b/mock/server.py index 336aa8302..19c4c29a1 100644 --- a/mock/server.py +++ b/mock/server.py @@ -553,4 +553,4 @@ def unixfile_copy(subpath): return {"msg": "Successfully copied the directory/file"}, 200 if __name__ == '__main__': - app.run(debug=True) + app.run(debug=True) \ No newline at end of file From f4fd7eac21367218cc787adcae07b2fb6e6b40c1 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Tue, 7 Dec 2021 11:07:21 -0500 Subject: [PATCH 8/9] Removed idea folder Signed-off-by: Alexandra Drazilov --- mock/.idea/workspace.xml | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 mock/.idea/workspace.xml diff --git a/mock/.idea/workspace.xml b/mock/.idea/workspace.xml deleted file mode 100644 index 774d38ec7..000000000 --- a/mock/.idea/workspace.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - 1638241863737 - - - - \ No newline at end of file From e002fb644a430046dfe226365d8d178419c29889 Mon Sep 17 00:00:00 2001 From: Alexandra Drazilov Date: Fri, 17 Dec 2021 10:59:43 -0500 Subject: [PATCH 9/9] Changed newName is to newName == Signed-off-by: Alexandra Drazilov --- mock/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mock/server.py b/mock/server.py index 19c4c29a1..bc1168ec3 100644 --- a/mock/server.py +++ b/mock/server.py @@ -526,7 +526,7 @@ def unixfile_copy(subpath): if request.method == 'POST': directory = global_directory newName = request.args.get('newName') - if(newName is None or newName is ""): + if(newName is None or newName == ""): return {"msg": "newName query parameter is missing."}, 400 newNames = newName.split("/") currPath = directory["contents"]