sumatrapdf icon indicating copy to clipboard operation
sumatrapdf copied to clipboard

File tracking failure occurs when a different file with the same name directly replace the original one.

Open zymelaii opened this issue 2 years ago • 10 comments

I noticed that when a file with same name was moved to cover the on-tracked file, SumatraPDF did not regard it as an update. However, under any other cases, the tracking procedure works fine. It really fuzied me as my xelatex driver always generates new PDF via a move-and-cover method and then, the viewer won't be refreshed.

zymelaii avatar Aug 12 '22 06:08 zymelaii

I consider it as an syscall limitation. But if it is possible to fix the bug internally, it can be a great deal!

zymelaii avatar Aug 12 '22 06:08 zymelaii

Depends how a file is rebuilt, traditionally LaTeX.pdf under 10 MB were auto refreshed on re compile, the limit should now be 32MB there are system factors that can delay the signal to refresh such as other file interference by AntiVirus or File Syncronisation outside SumatraPDF control.

Silly example externally file was changed (same filename) by replace with icon in fresh position and SumatraPDF auto refreshed simply on that external reposition.

image image

GitHubRulesOK avatar Aug 15 '22 15:08 GitHubRulesOK

Can you provide a reproduction steps, preferably one that doesn't use xelatex but some simple way to reproduce the problem?

kjk avatar Sep 26 '22 01:09 kjk

Can you provide a reproduction steps, preferably one that doesn't use xelatex but some simple way to reproduce the problem?

Simply generate pdf A under folder T, and PDF B under folder G via any methods (note that B differs from A). Open A in the SumatraPDF then execute shell e.g. `mv -f G/B.pdf T/A.pdf' - no changes in the SumatraPDF after that.

I found only latexmk with xelatex driver sometimes performs like this, while others work well.

zymelaii avatar Sep 26 '22 01:09 zymelaii

Typing "R" (refresh) is a workaround, but I confirm this problem happens in my Quarto builds (latex is used under the hood, but the quarto build process deletes the PDF at the start, and so when it's rebuilt it is technically a new file).

Note that Quarto has its own PDF previewer via a web interface (it starts up a web server running on localhost and you open the PDF in a browser). So updating works, more or less, but I find it clunky especially when the localhost port changes. For these reasons, I prefer SumatraPDF.

fuhrmanator avatar Nov 07 '22 16:11 fuhrmanator

This sounds awfully similar to the problem I documented in https://github.com/SublimeText/LaTeXTools/issues/1373. It used to work before W10 1709.

It really fuzied me as my xelatex driver always generates new PDF via a move-and-cover method and then

That could explain why latex tools are so special and nobody else in the hell seems to notice. I wonder if some slightly different implementations of the same we use here are also affected?

p.s. FWIW my testcase is running through tinytex a thesisdown document in RStudio (which comes with sumatra built-in btw)

mirh avatar Jan 12 '23 03:01 mirh

@kjk again I am reminded this issue has tones of the refresh problems encountered by some LaTeX users in recent https://github.com/sumatrapdfreader/sumatrapdf/issues/3774 so is it a common file replacement mis detection ?

GitHubRulesOK avatar Oct 20 '23 11:10 GitHubRulesOK

Isn't #3774 about something bad/undesired happening after refresh happens, as opposed to refresh not happening at all?

mirh avatar Oct 20 '23 12:10 mirh

@kjk I notice that moving file (or mv command) only causes a FILE_ACTION_ADDED notion. But sumatrapdf do nothing with it. May be let sumatrapdf treat FILE_ACTION_ADDED just same as FILE_ACTION_MODIFIED in line

if (notify->Action == FILE_ACTION_ADDED || notify->Action == FILE_ACTION_MODIFIED ||
            notify->Action == FILE_ACTION_RENAMED_NEW_NAME)

It seems worked, but I am not sure will this cause any other iusse else.

changlichun avatar Apr 11 '24 07:04 changlichun

@changlichun makes sense. probably won't break anything. Would you like to make a PR?

kjk avatar Apr 11 '24 10:04 kjk