Timothy J. Baek hai 7 meses
pai
achega
6fdfa62845
Modificáronse 1 ficheiros con 11 adicións e 7 borrados
  1. 11 7
      src/lib/components/workspace/Knowledge/Collection.svelte

+ 11 - 7
src/lib/components/workspace/Knowledge/Collection.svelte

@@ -308,15 +308,19 @@
 
 
 	// Helper function to maintain file paths within zip
 	// Helper function to maintain file paths within zip
 	const syncDirectoryHandler = async () => {
 	const syncDirectoryHandler = async () => {
-		const res = await resetKnowledgeById(localStorage.token, id).catch((e) => {
-			toast.error(e);
-		});
+		if ((knowledge?.files ?? []).length > 0) {
+			const res = await resetKnowledgeById(localStorage.token, id).catch((e) => {
+				toast.error(e);
+			});
 
 
-		if (res) {
-			knowledge = res;
-			toast.success($i18n.t('Knowledge reset successfully.'));
+			if (res) {
+				knowledge = res;
+				toast.success($i18n.t('Knowledge reset successfully.'));
 
 
-			// Upload directory
+				// Upload directory
+				uploadDirectoryHandler();
+			}
+		} else {
 			uploadDirectoryHandler();
 			uploadDirectoryHandler();
 		}
 		}
 	};
 	};