Markpad icon indicating copy to clipboard operation
Markpad copied to clipboard

Do not clear the temporary files

Open ProudRabbit opened this issue 3 months ago • 24 comments

Markpad version

2.7.5

How did you install it?

Windows — portable (Markpad_….exe)

OS and version

Windows 10 22H2

What happens, and what you expected instead

每次我保存文件(Ctrl+s)时,MarkPad 都会创建一个临时文件。当我关闭文档和 MarkPad 时,这些临时文件不会被删除。

-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:18 .验证结果.md.markpad-tmp-23436-1787728728439865400-4
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:18 .验证结果.md.markpad-tmp-23436-1787728730336559800-5
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:18 .验证结果.md.markpad-tmp-23436-1787728733734697700-6
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 14:45 .验证结果.md.markpad-tmp-27716-1787726751459097400-4
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:25 .验证结果.md.markpad-tmp-33956-1787729117209943400-3
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:26 .验证结果.md.markpad-tmp-33956-1787729161741606400-6
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:26 .验证结果.md.markpad-tmp-33956-1787729168309099600-7
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:24 .验证结果.md.markpad-tmp-34932-1787729079878793300-3
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:24 .验证结果.md.markpad-tmp-34932-1787729081838730000-4
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:24 .验证结果.md.markpad-tmp-34932-1787729085054630400-5
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:24 .验证结果.md.markpad-tmp-34932-1787729085103535000-6
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:22 .验证结果.md.markpad-tmp-35040-1787728960314673700-4
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:22 .验证结果.md.markpad-tmp-35040-1787728962072154900-5
-rw-r--r-- 1 xxxxxx 1049089      0 Aug 26 15:22 .验证结果.md.markpad-tmp-35040-1787728966143101300-6
-rw-r--r-- 1 xxxxxx 1049089  11961 Aug 26 15:26 验证结果.md

Steps to reproduce

  1. Open file.
  2. Edit file.
  3. Press Ctrl+s

The Markdown that triggers it


Screenshots, and anything else

No response

ProudRabbit avatar Aug 26 '26 07:08 ProudRabbit

get it

PathGao avatar Aug 27 '26 00:08 PathGao

@alecdotdev emergency stop shipping 2.7.5。I will fix it and ship 2.7.6 in few minutes

PathGao avatar Aug 27 '26 00:08 PathGao

fixed but really sorry for that

PathGao avatar Aug 27 '26 00:08 PathGao

you will get 2.7.6 soon

PathGao avatar Aug 27 '26 00:08 PathGao

No worries at all, thanks for the quick fix! I really like Mardpad.

The problem seems not to have been fixed. I tested it on the 2.7.6 portable version, and the phenomenon remained the same. Perhaps it's a problem with the computer. I'll test it in the virtual machine later. Wait for my good news.

ProudRabbit avatar Aug 27 '26 01:08 ProudRabbit

I tested it in the virtual machine and found no abnormalities. Perhaps there are some restrictions imposed by the company's IT department on the use of computers.

ProudRabbit avatar Aug 27 '26 01:08 ProudRabbit

I tested it in the virtual machine and found no abnormalities. Perhaps there are some restrictions imposed by the company's IT department on the use of computers.我在虚拟机上测试过,没有发现任何异常。可能是公司 IT 部门对电脑使用做了一些限制。

2.7.6 shipped。The real problem is, it cant creat new flie anymore。Bug is much bigger than your issue

我拿中文讲了,我发现这实际上是一个和我那个巨大的bug完全不同的问题,而且这个fix我无法验证。很有可能是,我们因为有自动保存(你可以关掉),然后导致你公司机器上会有问题,而虚拟机不会。等一下我的bot会问你几个问题麻烦帮忙一起check一下。而且,这个fix要几周才会和下一个版本ship吧。我们现在很稳定没什么issue报过来,也没什么bug要修,feature要加

PathGao avatar Aug 27 '26 02:08 PathGao

Thanks for the listing — that made this much easier to look at.

Markpad writes a save to a temp file next to your document and then renames it into place, so a temp file left behind means the save either failed or its cleanup was blocked. #725 makes both less likely and also deletes leftovers from earlier sessions the next time you save that document.

Three things would tell me whether that is the whole story, because the files being 0 bytes suggests the writes themselves were failing:

  1. When you press Ctrl+S, do you ever see an error message in the app (a red toast saying the save failed)? Or does saving always look successful?
  2. Where does 验证结果.md live — a normal local folder, OneDrive, a network drive, or a folder covered by Windows' "Controlled folder access" (受控文件夹访问)?
  3. Which antivirus is running?

多谢你贴的文件列表,帮了大忙。

Markpad 保存时先写一个临时文件,再改名覆盖原文件,所以临时文件留下来说明保存失败了、或者清理被挡住了。#725 让这两种情况更不容易发生,并且下次保存同一个文档时会把之前遗留的临时文件一起删掉。

不过那些文件都是 0 字节,看着像写入本身就没成功,所以还想确认三件事:

  1. 按 Ctrl+S 的时候,有没有见过保存失败的红色错误提示?还是每次看起来都保存成功了?
  2. 验证结果.md 放在什么位置——普通本地文件夹、OneDrive、网络盘,还是在 Windows「受控文件夹访问」保护的目录下?
  3. 用的是哪个杀毒软件?

PathGao avatar Aug 27 '26 02:08 PathGao

  1. 按 Ctrl+S 没有任何异常提示,并且标签栏上用于标志文件已修改的原点会同步消失。
  2. 验证结果.md 存放在普通本地文件夹。
  3. 亚信安全TrustOne

ProudRabbit avatar Aug 27 '26 02:08 ProudRabbit

你可以试一下关闭自动保存会如何嘛

PathGao avatar Aug 27 '26 03:08 PathGao

关闭后问题依旧。

ProudRabbit avatar Aug 27 '26 03:08 ProudRabbit

谢谢,这三条回答很关键。

它们基本排除了 Markpad 这边保存失败:没有报错、修改点消失、文件内容也是新的,说明改名这一步是成功的 —— 而一次成功的改名本来就不该把旧名字留在目录里。关掉自动保存问题依旧、虚拟机又完全正常,所以现在看更像是这台机器上的文件系统过滤驱动(亚信安全 TrustOne 这类端点安全软件)在改名前后留下的痕迹。

想请你帮忙做一个小实验,不要开 Markpad,在放 验证结果.md 的那个文件夹里用 cmd 跑这三行:

echo test> .probe.markpad-tmp
ren .probe.markpad-tmp probe.txt
dir /a .probe*

如果 .probe.markpad-tmp 还在,那就跟 Markpad 无关了,任何"先写临时文件再改名"的程序(VS Code、Git 都是这么保存的)在这台机器上都会留下同样的东西。

不管实验结果如何,下个版本都会带上 #725:保存完会回头把这个多出来的文件删掉,之前遗留的那一批也会在你下次保存同一个文档时一起清掉。你能看到的效果是文件夹保持干净。


Thanks — those three answers were the useful ones.

They rule out a failed save on Markpad's side: no error, the modified dot clears, and the file holds the new text, so the rename succeeded — and a successful rename should not leave the old name in the directory. Auto-save off changes nothing and your VM is clean, so this now looks like a filesystem filter driver on that machine (endpoint security such as TrustOne) leaving the source name behind.

Could you try this with Markpad closed, in the folder that holds 验证结果.md, from cmd:

echo test> .probe.markpad-tmp
ren .probe.markpad-tmp probe.txt
dir /a .probe*

If .probe.markpad-tmp is still there, this is not about Markpad — any program that saves by writing a temp file and renaming it (VS Code and Git both do) will leave the same thing on that machine.

Either way the next release will carry #725: after a save Markpad looks for that extra file and deletes it, and leftovers from earlier sessions are cleared the next time you save that document. What you should see is the folder staying clean.

PathGao avatar Aug 27 '26 09:08 PathGao

昨天下班了,这是今早的验证结果。不知为何图片一直上传失败,只好复制指令的执行结果了。

D:\03_Code\02_PrivateRepo\test>echo test> .probe.markpad-tmp

D:\03_Code\02_PrivateRepo\test>ren .probe.markpad-tmp probe.txt

D:\03_Code\02_PrivateRepo\test>dir /a .probe*
 驱动器 D 中的卷是 软件
 卷的序列号是 BAE2-A817

 D:\03_Code\02_PrivateRepo\test 的目录

找不到文件

D:\03_Code\02_PrivateRepo\test>

ProudRabbit avatar Aug 28 '26 01:08 ProudRabbit

谢谢,干净的结果同样有用 —— 它排除了"这台机器上任何改名都会留下痕迹",所以问题出在 Markpad 保存的方式和你刚才那条命令的差别上。差别只剩几点,其中一点在我们这边:Markpad 改名的时候,自己对临时文件的句柄还开着,而 echo 是写完就关。#725 已经把这条改掉了,另外还加了一道保险——改名成功后回头看一眼,那个文件还在就删掉。

与其继续猜,能不能请你直接跑一下带修复的版本?#725 的 Windows 构建在这里,登录 GitHub 后在页面底部下载 app-bundle-windows,里面就是便携版 exe:

https://github.com/sftwrdotdev/Markpad/actions/runs/33069325286

用它编辑保存几次,看文件夹里还会不会出现临时文件就行。

另外确认一件事:验证结果.md 是不是就放在 D:\03_Code\02_PrivateRepo\test?如果不是,麻烦在它真正所在的那个文件夹里再跑一次刚才那三行命令 —— 不同目录上的安全策略可能不一样。


Thanks — a clean result is just as useful. It rules out "every rename on this machine leaves something behind", so the difference has to be in how Markpad saves versus what you just ran. Only a few differences are left, and one of them is ours: Markpad renames the temp file while its own handle on it is still open, where echo closes the file before ren. #725 changes that, and also adds a backstop — after a successful rename it looks for the file that should be gone and deletes it.

Rather than keep guessing, could you run the build with the fix? The Windows build of #725 is here — sign in to GitHub and download app-bundle-windows at the bottom of the page; it contains the portable exe:

https://github.com/sftwrdotdev/Markpad/actions/runs/33069325286

Edit and save a few times, and see whether temp files still appear.

One more thing to confirm: does 验证结果.md live in D:\03_Code\02_PrivateRepo\test? If not, please run those three commands again in the folder it actually lives in — the security policy can differ between folders.

PathGao avatar Aug 28 '26 03:08 PathGao

验证结果.md 是放在在 D:\03_Code\02_PrivateRepo\test 下。

使用 https://github.com/sftwrdotdev/Markpad/pull/725 Windows 构建的版本现象依旧。

Image

ProudRabbit avatar Aug 28 '26 05:08 ProudRabbit

谢谢,这次的截图信息量很大:全新的文件夹、全新的 test.md,一保存就长一个 0 字节文件,所以跟目录和历史遗留都没关系。

带修复的版本里,Markpad 在改名成功后本来就会回头把这个文件删掉,而你那五个还在。只可能是两种情况,麻烦你帮我分一下,都不费事:

  1. 关掉 Markpad,在资源管理器里直接删掉其中一个 0 字节文件 —— 删得掉吗?如果删不掉,弹出的提示原文是什么?
  2. 关掉 Markpad 再重新打开、打开 test.md,之前留下的那几个是不是自己消失了?

如果第 1 条删不掉,说明有别的程序按着这些文件,Markpad 在保存时怎么删都删不掉,只能等它松手之后再清;如果删得掉,说明这些文件是在 Markpad 检查之后才出现的,那我们要改成隔几分钟重扫一次,而不是一次运行只扫一次。


Thanks — this screenshot says a lot: a brand new folder, a brand new test.md, one 0-byte file per save. So it is not about the folder and not about old leftovers.

In the build you tested, Markpad already looks for that file after a successful rename and deletes it — and your five are still there. There are only two ways that happens, and both of these are quick to check:

  1. Close Markpad, then delete one of the 0-byte files in Explorer — does it delete? If not, what exactly does the error say?
  2. Close Markpad, open it again and open test.md — do the earlier ones disappear on their own?

If (1) refuses, something else is holding those files and no delete at save time can remove them — they can only be cleared later, once it lets go. If (1) works, they are appearing after Markpad's check, and the fix is to re-scan every few minutes rather than once per run.

PathGao avatar Aug 28 '26 05:08 PathGao

有时间方便的话麻烦帮忙测一下,我看看到底是什么问题,感谢

PathGao avatar Sep 01 '26 15:09 PathGao

补充一个更直接的实验,比上面两条更能一锤定音。

先说我这边看到的:保存成功之后,旧名字上才出现一个 0 字节的新文件。改名本身不会把数据留在旧名字上,所以这个空文件是别的程序后来造出来的,不是 Markpad 没删干净。带修复的版本只在改名后那一瞬间看一眼,文件晚一点出现它就看不到了,这就是为什么 #725 的构建上还是一次保存一个。

所有线索都指向亚信安全 TrustOne 的文件保护功能:一个它不认识的程序(Markpad 的 Windows 版没有签名)把自己刚建的文件"删掉"了,它把文件恢复回来,恢复出来的是空的。cmd 里干净是因为 cmd 是受信任的程序,虚拟机干净是因为没装它。

麻烦帮忙试这两步:

  1. 在 TrustOne 里把 Markpad.exe 加进信任/白名单,再保存几次,看还会不会出现空文件。
  2. 看一下 TrustOne 的防护日志里有没有关于 markpad.exe 的「文件恢复」或类似记录。

如果加白名单后就没了,那这个问题就定性了:是端点软件的行为,Markpad 从内部绕不过去。上面问的"能不能手动删"和"重开后会不会消失"仍然有用,方便的话一起回一下。


One more experiment, more decisive than the two above.

What I can see from the code: after a successful save, a new 0-byte file appears at the old temp name. A rename never leaves data behind at the old name, so this empty file is created afterwards by something else, not left over by Markpad. The build with the fix only checks once, right after the rename, so a file that shows up slightly later is never seen — which is why #725's build still leaves one per save.

Everything points to TrustOne's file protection: a program it does not recognise (Markpad's Windows build is unsigned) "deletes" a file it just created, and TrustOne restores it, as an empty file. cmd is clean because cmd is trusted; the VM is clean because TrustOne is not installed there.

Could you try:

  1. Add Markpad.exe to TrustOne's trust list / allowlist, save a few times, and see whether the empty files still appear.
  2. Check TrustOne's protection log for any "file restore" or similar entries mentioning markpad.exe.

If the allowlist makes it stop, that settles it: endpoint software behaviour that Markpad cannot work around from inside. The two earlier questions (can you delete the files by hand, do they vanish after a restart) are still useful — please answer those too when you get a chance.

PathGao avatar Sep 02 '26 00:09 PathGao

抱歉,最近比较忙没有及时回复。

  1. 资源管理器中可以直接删除,没有任何异常。
  2. 关闭 Markpad 再打开后,临时文件没有消失。

谢谢,这次的截图信息量很大:全新的文件夹、全新的 test.md,一保存就长一个 0 字节文件,所以跟目录和历史遗留都没关系。

带修复的版本里,Markpad 在改名成功后本来就会回头把这个文件删掉,而你那五个还在。只可能是两种情况,麻烦你帮我分一下,都不费事:

  1. 关掉 Markpad,在资源管理器里直接删掉其中一个 0 字节文件 —— 删得掉吗?如果删不掉,弹出的提示原文是什么?
  2. 关掉 Markpad 再重新打开、打开 test.md,之前留下的那几个是不是自己消失了?

如果第 1 条删不掉,说明有别的程序按着这些文件,Markpad 在保存时怎么删都删不掉,只能等它松手之后再清;如果删得掉,说明这些文件是在 Markpad 检查之后才出现的,那我们要改成隔几分钟重扫一次,而不是一次运行只扫一次。

Thanks — this screenshot says a lot: a brand new folder, a brand new test.md, one 0-byte file per save. So it is not about the folder and not about old leftovers.

In the build you tested, Markpad already looks for that file after a successful rename and deletes it — and your five are still there. There are only two ways that happens, and both of these are quick to check:

  1. Close Markpad, then delete one of the 0-byte files in Explorer — does it delete? If not, what exactly does the error say?
  2. Close Markpad, open it again and open test.md — do the earlier ones disappear on their own?

If (1) refuses, something else is holding those files and no delete at save time can remove them — they can only be cleared later, once it lets go. If (1) works, they are appearing after Markpad's check, and the fix is to re-scan every few minutes rather than once per run.

  1. 我没有权限在 TrustOne 中添加白名单。
  2. 防护日志中没有看到关于 markpad.exe 的「文件恢复」或类似记录。也有可能是我的权限看不到。

补充一个更直接的实验,比上面两条更能一锤定音。

先说我这边看到的:保存成功之后,旧名字上才出现一个 0 字节的新文件。改名本身不会把数据留在旧名字上,所以这个空文件是别的程序后来造出来的,不是 Markpad 没删干净。带修复的版本只在改名后那一瞬间看一眼,文件晚一点出现它就看不到了,这就是为什么 #725 的构建上还是一次保存一个。

所有线索都指向亚信安全 TrustOne 的文件保护功能:一个它不认识的程序(Markpad 的 Windows 版没有签名)把自己刚建的文件"删掉"了,它把文件恢复回来,恢复出来的是空的。cmd 里干净是因为 cmd 是受信任的程序,虚拟机干净是因为没装它。

麻烦帮忙试这两步:

  1. 在 TrustOne 里把 Markpad.exe 加进信任/白名单,再保存几次,看还会不会出现空文件。
  2. 看一下 TrustOne 的防护日志里有没有关于 markpad.exe 的「文件恢复」或类似记录。

如果加白名单后就没了,那这个问题就定性了:是端点软件的行为,Markpad 从内部绕不过去。上面问的"能不能手动删"和"重开后会不会消失"仍然有用,方便的话一起回一下。

One more experiment, more decisive than the two above.

What I can see from the code: after a successful save, a new 0-byte file appears at the old temp name. A rename never leaves data behind at the old name, so this empty file is created afterwards by something else, not left over by Markpad. The build with the fix only checks once, right after the rename, so a file that shows up slightly later is never seen — which is why #725's build still leaves one per save.

Everything points to TrustOne's file protection: a program it does not recognise (Markpad's Windows build is unsigned) "deletes" a file it just created, and TrustOne restores it, as an empty file. cmd is clean because cmd is trusted; the VM is clean because TrustOne is not installed there.

Could you try:

  1. Add Markpad.exe to TrustOne's trust list / allowlist, save a few times, and see whether the empty files still appear.
  2. Check TrustOne's protection log for any "file restore" or similar entries mentioning markpad.exe.

If the allowlist makes it stop, that settles it: endpoint software behaviour that Markpad cannot work around from inside. The two earlier questions (can you delete the files by hand, do they vanish after a restart) are still useful — please answer those too when you get a chance.

ProudRabbit avatar Sep 02 '26 00:09 ProudRabbit

我在用今天最新出的fable 5.1 好强啊,找问题根本原因能力非常强

PathGao avatar Sep 02 '26 01:09 PathGao