From 43682944dec828153dbf3286b043599b7124d888 Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 14 May 2025 14:23:25 +0200 Subject: [PATCH 1/5] [sc-243809] recursive folder deletion --- .../fs-provider.py | 31 +++++++++++++++++-- python-lib/sharepoint_client.py | 3 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/python-fs-providers/sharepoint-online_shared-documents/fs-provider.py b/python-fs-providers/sharepoint-online_shared-documents/fs-provider.py index 2a05133..23f5ae2 100644 --- a/python-fs-providers/sharepoint-online_shared-documents/fs-provider.py +++ b/python-fs-providers/sharepoint-online_shared-documents/fs-provider.py @@ -204,10 +204,35 @@ def delete_recursive(self, path): return 1 if folder is not None: + file_count = self.delete(get_lnt_path(full_path)) + logger.info("deleting folder '{}'".format(get_lnt_path(full_path))) self.client.recycle_folder(get_lnt_path(full_path)) - return 1 - - return 0 + return file_count + + return file_count + + def delete(self, path, file_count=0): + # logger.info("call delete '{}'".format(path)) + files = self.client.get_files(path) + files = self.client.extract_results(files) + for file in files: + file_name = file.get("Name") + if file_name: + file_path = "/".join([path, file_name]) + logger.info("deleting file '{}'".format(get_lnt_path(file_path))) + self.client.recycle_file(get_lnt_path(file_path)) + file_count += 1 + folders = self.client.get_folders(path) + folders = self.client.extract_results(folders) + for folder in folders: + folder_name = folder.get("Name") + if folder_name: + folder_path = "/".join([path, folder_name]) + # logger.info("deleting content of folder '{}'".format(get_lnt_path(folder_path))) + file_count = self.delete(get_lnt_path(folder_path), file_count) + logger.info("deleting folder '{}'".format(get_lnt_path(folder_path))) + self.client.recycle_folder(get_lnt_path(folder_path)) + return file_count def move(self, from_path, to_path): assert_valid_sharepoint_path(from_path) diff --git a/python-lib/sharepoint_client.py b/python-lib/sharepoint_client.py index 923258e..881a736 100644 --- a/python-lib/sharepoint_client.py +++ b/python-lib/sharepoint_client.py @@ -802,8 +802,7 @@ def get_list_default_view_url(self, list_title): ) def get_path_as_query_string(self, path): - if path: - if path == '/': + if path is None or path == '/': path = "" return "?@a1='{}'".format( url_encode(self.get_site_path(path)) From 19259c0965b1188612e857357b4bdb43af0ffa1c Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 14 May 2025 14:26:54 +0200 Subject: [PATCH 2/5] v1.1.7 --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index 9f1bbbc..3aca14d 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "id": "sharepoint-online", - "version": "1.1.6", + "version": "1.1.7", "meta": { "label": "SharePoint Online", "description": "Read and write data from/to your SharePoint Online account", From 076a14e9b64ef6437e23c121007f94fd74a700b0 Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 14 May 2025 14:27:06 +0200 Subject: [PATCH 3/5] beta.1 --- python-lib/dss_constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-lib/dss_constants.py b/python-lib/dss_constants.py index 6e4f7d3..9a31951 100644 --- a/python-lib/dss_constants.py +++ b/python-lib/dss_constants.py @@ -37,7 +37,7 @@ class DSSConstants(object): "sharepoint_oauth": "The access token is missing" } PATH = 'path' - PLUGIN_VERSION = "1.1.6" + PLUGIN_VERSION = "1.1.7-beta.1" SECRET_PARAMETERS_KEYS = ["Authorization", "sharepoint_username", "sharepoint_password", "client_secret", "client_certificate", "passphrase"] SITE_APP_DETAILS = { "sharepoint_tenant": "The tenant name is missing", From ae160ccf8e0a43b61e1b21d38b74aa4d81f656d9 Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 14 May 2025 14:27:17 +0200 Subject: [PATCH 4/5] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c1b098..4354120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [Version 1.1.7](https://github.com/dataiku/dss-plugin-sharepoint-online/releases/tag/v1.1.7) - Bugfix release - 2025-05-14 + +- Add recursive folder deletion + ## [Version 1.1.6](https://github.com/dataiku/dss-plugin-sharepoint-online/releases/tag/v1.1.6) - Bugfix release - 2025-04-01 - Fix issue with 255+ chars file paths. The new limit is 400 chars, imposed by SharePoint's API. From 3273aecf0dc7997b0645db0e260828c6986fe374 Mon Sep 17 00:00:00 2001 From: Alex Bourret Date: Wed, 14 May 2025 14:40:20 +0200 Subject: [PATCH 5/5] Fix issue when path to delete points to nothing --- .../sharepoint-online_shared-documents/fs-provider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-fs-providers/sharepoint-online_shared-documents/fs-provider.py b/python-fs-providers/sharepoint-online_shared-documents/fs-provider.py index 23f5ae2..13a7d42 100644 --- a/python-fs-providers/sharepoint-online_shared-documents/fs-provider.py +++ b/python-fs-providers/sharepoint-online_shared-documents/fs-provider.py @@ -209,7 +209,7 @@ def delete_recursive(self, path): self.client.recycle_folder(get_lnt_path(full_path)) return file_count - return file_count + return 0 def delete(self, path, file_count=0): # logger.info("call delete '{}'".format(path))