Skip to content

A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.

Move a data folder that is itself a link

Fei2411ac6b87f0db53
diff --git a/app/src/move-data.mjs b/app/src/move-data.mjs
index 427a8188..d7129f62 100644
--- a/app/src/move-data.mjs
+++ b/app/src/move-data.mjs
@@ -80,21 +80,23 @@ export async function copyData(from, to, signal) {
try {
await writeFile(join(stage, MARK), '')
const links = []
- await cp(from, stage, {
+ // The data folder can itself be a link; its contents are what moves.
+ const origin = real(from)
+ await cp(origin, stage, {
recursive: true,
filter: async (source) => {
signal?.throwIfAborted()
- const path = relative(from, source)
+ const path = relative(origin, source)
if (LEFT_BEHIND.some(pattern => pattern.test(path))) return false
if (path === '' || !(await lstat(source)).isSymbolicLink()) return true
links.push(path)
return false
},
})
- const roots = [...new Set([resolve(from), real(from)])]
+ const roots = [...new Set([resolve(from), origin])]
for (const path of links) {
signal?.throwIfAborted()
- await relink(join(from, path), join(stage, path), roots, resolve(to))
+ await relink(join(origin, path), join(stage, path), roots, resolve(to))
}
signal?.throwIfAborted()
await rm(join(stage, MARK))
diff --git a/app/test/move-data.test.mjs b/app/test/move-data.test.mjs
index f5b42b24..4f4dda5b 100644
--- a/app/test/move-data.test.mjs
+++ b/app/test/move-data.test.mjs
@@ -109,6 +109,13 @@ test('a folder that a link leads into counts as that folder', (t) => {
assert.equal(moveProblem({ from, to: join(root, 'data-link', 'inside'), dshHome: join(root, 'dsh') }), 'nested')
})
+test('a data folder that is itself a link moves with its contents', async (t) => {
+ const { root, from } = setup(t)
+ symlinkSync(from, join(root, 'data-link'), folderLink)
+ await copyData(join(root, 'data-link'), join(root, 'new'))
+ assert.deepEqual(files(join(root, 'new')), ['.credentials.yaml', 'bot/state.json', 'sessions/g/s1/log.jsonl'])
+})
+
test('links in the data lead inside the copy, not back into the old folder', async (t) => {
const { root, from } = setup(t)
symlinkSync(join(from, 'sessions'), join(from, 'bot', 'absolute'), folderLink)