A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Keep a relative link out of the old data leading where it led
Fei2411bd35d7e85272
diff --git a/app/src/move-data.mjs b/app/src/move-data.mjsindex 61dd9a2f..3b7d7069 100644--- a/app/src/move-data.mjs+++ b/app/src/move-data.mjs@@ -46,17 +46,18 @@ export function moveProblem(places) {const escaped = text => text.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')-// Links keep their text, so relative ones still lead inside the copy; absolute ones that led-// into the old folder lead into the new one. Windows gives a junction's target with \\?\, and-// makes only junctions without special rights.+// A link that leads inside the old folder leads to the same place inside the copy: a relative+// one keeps its text, an absolute one is moved over. One that leads outside keeps leading+// there, as an absolute link. Windows gives a junction's target with \\?\, and makes only+// junctions, which hold absolute paths, without special rights.async function relink(source, path, roots, to) {- const text = await readlink(source)- const target = text.replace(/^\\\\\?\\/u, '')- const root = isAbsolute(target) ? roots.find(folder => within(target, folder)) : undefined+ const text = (await readlink(source)).replace(/^\\\\\?\\/u, '')+ const target = resolve(dirname(source), text)+ const root = roots.find(folder => within(target, folder))const folder = (await stat(source).catch(() => undefined))?.isDirectory() === trueconst windows = process.platform === 'win32'- if (root !== undefined) await symlink(join(to, relative(root, target)), path, folder ? (windows ? 'junction' : 'dir') : 'file')- else await symlink(windows && folder ? target : text, path, folder ? (windows ? 'junction' : 'dir') : 'file')+ const inside = root === undefined ? target : join(to, relative(root, target))+ await symlink(root !== undefined && !isAbsolute(text) && !(windows && folder) ? text : inside, path, folder ? (windows ? 'junction' : 'dir') : 'file')}/**diff --git a/app/test/move-data.test.mjs b/app/test/move-data.test.mjsindex d1013391..19e8395a 100644--- a/app/test/move-data.test.mjs+++ b/app/test/move-data.test.mjs@@ -112,14 +112,21 @@ test('a folder that a link leads into counts as that folder', (t) => {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)- if (process.platform !== 'win32') symlinkSync(join('..', 'sessions'), join(from, 'bot', 'relative'), 'dir')write(join(root, 'elsewhere', 'file.txt'), 'x')symlinkSync(join(root, 'elsewhere'), join(from, 'bot', 'outside'), folderLink)- const to = join(root, 'new')+ if (process.platform !== 'win32') {+ symlinkSync(join('..', 'sessions'), join(from, 'bot', 'relative'), 'dir')+ symlinkSync(join('..', '..', 'elsewhere'), join(from, 'bot', 'relative-outside'), 'dir')+ }+ // Deeper than the old folder, so that a relative link out of it would lead elsewhere.+ const to = join(root, 'deeper', 'new')await copyData(from, to)const target = name => readlinkSync(join(to, 'bot', name)).replace(/^\\\\\?\\/u, '').replace(/[\\/]+$/u, '')assert.equal(target('absolute'), join(to, 'sessions'))assert.equal(target('outside'), join(root, 'elsewhere'))- if (process.platform !== 'win32') assert.equal(readlinkSync(join(to, 'bot', 'relative')), join('..', 'sessions'))+ if (process.platform !== 'win32') {+ assert.equal(target('relative'), join('..', 'sessions'))+ assert.equal(target('relative-outside'), join(root, 'elsewhere'))+ }assert.equal(readFileSync(join(to, 'bot', 'absolute', 'g', 's1', 'log.jsonl'), 'utf8'), 'chat')})