bugPSPP - Bugs: bug #25795, Problem saving changes

 
 

bug #25795: Problem saving changes

Submitted by:  Michel Boaventura <michelboaventura>
Submitted on:  Sun 08 Mar 2009 10:06:17 PM UTC  
 
Category:  Graphical User Interface Severity:  5 - Average
Status:  Fixed Assigned to:  None
Open/Closed:  Closed Release:  None
Effort:  0.00

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

( Jump to the original submission)

Wed 08 Apr 2009 08:24:55 AM UTC, comment #8: 

This has now been fixed.  Thanks to Ben Pfaff for getting the necessary patch into gnulib.

John Darrington <jmd>
Project Administrator
Fri 20 Mar 2009 03:27:09 AM UTC, comment #7: 

It works. I can save a file just clicking on the "SAVE" button.

What I did was change the "rename" to:
ok = MoveFileEx(rf->tmp_name, rf->file_name, MOVEFILE_REPLACE_EXISTING) != 0;

and insert an "#include <windows.h>" on the top of the file.

I need to use "!= 0" because it only returns zero if a error happens, the opposite of rename.

Michel Boaventura <michelboaventura>
Project Member
Fri 20 Mar 2009 03:13:31 AM UTC, comment #6: 

On Windows theres is a function called MoveFileEx:http://msdn.microsoft.com/en-us/library/aa365240(VS.85).aspx
It has two interesting options:

MOVEFILE_REPLACE_EXISTING: If a file named lpNewFileName exists, the function replaces its contents with the contents of the lpExistingFileName file...

We could use:
ok = MoveFileEx(rf->tmp_name, rf->file_name, MOVEFILE_REPLACE_EXISTING) != 0;

I will try it.

Michel Boaventura <michelboaventura>
Project Member
Fri 20 Mar 2009 02:59:36 AM UTC, comment #5: 

Unfortunately this isn't a correct solution to the problem.  It'll break a number of other things, because we need the destination to remain intact if renaming the file fails for any reason.

Currently we have:

 rename (rf->tmp_name, rf->file_name);

one solution would be to change this to:

 rename (rf->file_name, tmp2_name);
 if ( ! rename (rf->tmp_name, rf->file_name))
  rename (tmp2_name, rf->file_name);

but that brings some issues of its own.

Alternatively if there is a safe equivalent to "rename" in Mingw which can safely and atomically move files from one filesystem entry to another, then we could use that.

So we still have to come up with a solution to this problem, but at least we understand it better.

John Darrington <jmd>
Project Administrator
Fri 20 Mar 2009 02:44:39 AM UTC, comment #4: 

GREAT! It works. I did what you told and it fixes this issue.Thank you!

Michel Boaventura <michelboaventura>
Project Member
Fri 20 Mar 2009 02:18:00 AM UTC, comment #3: 

Looking through the code, it would appear that the file has been closed.  The error message doesn't complain that the file is open, simply that it exists.

What happens if you add      unlink (rf->file_name);
above the call to rename in make-file.c ?

John Darrington <jmd>
Project Administrator
Fri 20 Mar 2009 12:09:48 AM UTC, comment #2: 

Seems like its a problem with rename() function. On Linux it allows to rename an open file, but on windows it doesn't.
Looking at Posix theres nothing about rename an open file, so I don't know who is "right".

I've send an message to mingw list to see if theres an alternative to that.

Michel Boaventura <michelboaventura>
Project Member
Mon 09 Mar 2009 04:12:09 AM UTC, comment #1: 

>If I open a file on psppire(in this case teste2.sav file) and
>change anything on it and then click on "Save" button, I get:
>"PSPP error: Replacing teste2.sav.tmpcLzJvi by teste2.sav: File
>exists."


I don't have a solution, yet, but I can speculate on what is going on.  I suspect that PSPPIRE has teste2.sav still open at the time that it tries to replace it by a new version.  Under Unix, this works just fine.  But Windows forbids deleting or replacing an open file, so it fails (with the given error message).

>After that, if I close this error message, and close psppire, it
>doesn't ask me to save my file before close it.


That sounds like a separate bug, for what it's worth.  PSPPIRE should consider the file not to be saved if the save failed (as it did).

Ben Pfaff <blp>
Project Administrator
Sun 08 Mar 2009 10:06:17 PM UTC, original submission:  

If I open a file on psppire(in this case teste2.sav file) and change anything on it and then click on "Save" button, I get:
"PSPP error: Replacing teste2.sav.tmpcLzJvi by teste2.sav: File exists."

After that, if I close this error message, and close psppire, it doesn't ask me to save my file before close it.

If I open the file again, the changes aren't there.

Michel Boaventura <michelboaventura>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jmd (Posted a comment)
  • -email is unavailable- added by blp (Posted a comment)
  • -email is unavailable- added by michelboaventura (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2009-04-08 jmd StatusNone => Fixed
        Open/ClosedOpen => Closed

    Back to the top


    Powered by Savane 3.5