Created attachment 135556 [details] [review] Error out on save if file has changed since we opened it In poppler we keep the fd of the file open so the XRef+FileStream can locate objects. This is good since we save lots of memory for not having everything on memory all the time, but that means that when we want to save we need the file to be exactly the same as it was when we created the XRef otherwise we're going to be reading from the wrong part of the "new" file. The attached patch checks the modification time of the fd and errors out if it has changed since we opened the file. It's a stub in windows since my understanding there is that you can't edit a file that is open by another program.
(In reply to Albert Astals Cid from comment #0) > It's a stub in windows since my understanding there is that you can't edit a > file that is open by another program. You are not true, Albert. The files, at least with poppler, are opened with sharing enabled, i.e. HANDLE handle = CreateFileA(fileName->getCString(), GENERIC_READ, --> FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); That means that other processes are allowed to read and even write to the same file! But we can probably do the same under windows with GetFileTime, using the lpLastWriteTime parameter.
ok, then someone will have to provide the windows codepath i guess.
Created attachment 135735 [details] [review] win version for Error out on save if file has changed since we opened it Here the windows codepath.
Cool, i'll push this in a week if noone disagrees :)
Pushed
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.