git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] Work around leftover temporary save file.

From
Pat Thoyts <patthoyts@users.sourceforge.net>
Date
Sep 15, 2009, 14:47 UTC
Message-ID
<87tyz4b6z3.fsf@users.sourceforge.net>
In-Reply-To
<81b0412b0909150601j74d40181pc2308f4f63b4817e@mail.gmail.com>
Alex Riesen <raa.lkml@gmail.com> writes:
Show 27 quoted lines
>On Tue, Sep 15, 2009 at 11:26, Pat Thoyts
><patthoyts@users.sourceforge.net> wrote:
>>
>> If a file exists and is hidden on Windows the Tcl open command will
>> fail as the attributes provided in the CREAT call fail to match those
>> of the existing file. Forcing removal of the temporary file before we
>> begin solves any problems caused by previous failures to save the
>> application settings. An alternative would be to remove the hidden
>> attribute before calling 'open'.
>>
>> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
>> ---
>>  gitk |    1 +
>>  1 files changed, 1 insertions(+), 0 deletions(-)
>>
>> diff --git a/gitk b/gitk
>> index 1306178..a0214b7 100755
>> --- a/gitk
>> +++ b/gitk
>> @@ -2526,6 +2526,7 @@ proc savestuff {w} {
>>     if {$stuffsaved} return
>>     if {![winfo viewable .]} return
>>     catch {
>> +       if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new}
>
>maybe another gitk instance is writing it at exactly same moment
>in time? Writing is known to take a few moments. Especially on Windows.

no - 'open $file w' is translated into O_WRONLY|O_CREAT|O_TRUNC internally and passed to the win32 layer to get converted to a call to CreateFile with GENERIC_WRITE, CREATE_ALWAYS and FILE_ATTRIBUTE_NORMAL. The file has got FILE_ATTRIBUTE_HIDDEN though and as it exists and our attributes do not match we get failed. 'open $file {O_WRONLY O_TRUNC}' would open it but we'd have to check for non-existence and redo with O_CREAT if it was not already present.

See tclWinChan.c:TclpOpenFileChannel.
-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD
Previous: Pat ThoytsNext: Pat Thoyts
Message 6 of 16 in “gitk: restore wm state to normal before saving geometry information”
  1. gitk: restore wm state to normal before saving geometry informationAlexey Borzenkov, Sep 8, 2009
  2. 1/2 Work around leftover temporary save file.Pat Thoyts, Sep 15, 2009
  3. Alex RiesenSep 15, 2009
  4. Alexey BorzenkovSep 15, 2009
  5. Pat ThoytsSep 15, 2009
  6. Pat ThoytsSep 15, 2009
  7. 2/2 Fix the geometry when restoring from zoomed state.Pat Thoyts, Sep 15, 2009
  8. Alexey BorzenkovSep 15, 2009
  9. Paul MackerrasSep 17, 2009
  10. Alexey BorzenkovSep 17, 2009
  11. Pat ThoytsSep 18, 2009
  12. Pat ThoytsSep 15, 2009
  13. Alexey BorzenkovSep 15, 2009
  14. Alexey BorzenkovSep 15, 2009
  15. Paul MackerrasSep 16, 2009
  16. Pat ThoytsSep 16, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.