Skip to content

Commit 7b01175

Browse files
committed
Address comments
Signed-off-by: Daishan Peng <[email protected]>
1 parent f017900 commit 7b01175

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

actions/knowledge/knowledge.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,22 @@ export async function ensureFiles(
5757
fs.mkdirSync(dir, { recursive: true });
5858
}
5959

60-
for (const file of Array.from(files.entries())) {
61-
if (!fs.existsSync(path.join(dir, file[1].type))) {
62-
fs.mkdirSync(path.join(dir, file[1].type), { recursive: true });
60+
for (const [location, file] of Array.from(files.entries())) {
61+
if (!fs.existsSync(path.join(dir, file.type))) {
62+
fs.mkdirSync(path.join(dir, file.type), { recursive: true });
6363
}
64-
const filePath = path.join(dir, file[1].type, path.basename(file[0]));
64+
const filePath = path.join(dir, file.type, path.basename(location));
6565
if (!fs.existsSync(filePath)) {
66-
if (file[1].type === 'local') {
67-
await fs.promises.copyFile(file[0], filePath);
68-
} else if (file[1].type === 'notion' || file[1].type === 'onedrive') {
66+
if (file.type === 'local') {
67+
await fs.promises.copyFile(location, filePath);
68+
} else if (file.type === 'notion' || file.type === 'onedrive') {
6969
if (
7070
fs.existsSync(filePath) &&
7171
fs.lstatSync(filePath).isSymbolicLink()
7272
) {
7373
continue;
7474
}
75-
await fs.promises.symlink(file[0], filePath);
75+
await fs.promises.symlink(location, filePath);
7676
}
7777
}
7878
}

actions/knowledge/tool.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ export async function runSyncTool(
2020

2121
let toolUrl = '';
2222
if (tool === 'notion') {
23-
toolUrl = 'github.com/gptscript-ai/knowledge-notion-integration@46a273e';
23+
toolUrl = 'github.com/gptscript-ai/knowledge-notion-integration';
2424
} else if (tool === 'onedrive') {
25-
toolUrl = 'github.com/gptscript-ai/knowledge-onedrive-integration@ef73dff';
25+
toolUrl = 'github.com/gptscript-ai/knowledge-onedrive-integration';
2626
}
2727
const runningTool = await gptscript.run(toolUrl, {
2828
prompt: true,
@@ -53,14 +53,13 @@ export async function syncFiles(
5353
const metadataFromFiles = fs.readFileSync(path.join(dir, 'metadata.json'));
5454
const metadata = JSON.parse(metadataFromFiles.toString());
5555
for (const file of selectedFiles) {
56-
const t = path.basename(path.dirname(path.dirname(file)));
57-
if (t !== type) {
58-
continue;
56+
const baseDir = path.dirname(path.dirname(file));
57+
if (baseDir === dir) {
58+
const documentID = path.basename(path.dirname(file));
59+
const detail = metadata[documentID];
60+
detail.sync = true;
61+
metadata[documentID] = detail;
5962
}
60-
const documentID = path.basename(path.dirname(file));
61-
const detail = metadata[documentID];
62-
detail.sync = true;
63-
metadata[documentID] = detail;
6463
}
6564
fs.writeFileSync(path.join(dir, 'metadata.json'), JSON.stringify(metadata));
6665
await runSyncTool(true, type);

components/edit/configure.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ const Configure: React.FC<ConfigureProps> = ({ collapsed }) => {
8888
);
8989
setDroppedFiles((prev) => {
9090
const newMap = new Map(prev);
91-
for (const file of Array.from(files.entries())) {
92-
newMap.set(file[0], file[1]);
91+
for (const [location, file] of Array.from(files.entries())) {
92+
newMap.set(location, file);
9393
}
9494
return newMap;
9595
});

0 commit comments

Comments
 (0)