[ATTENTION], "problem" with FolderItem.Exists

jda jda at his.com
Mon Feb 21 10:03:56 CST 2005


>>Kevin, I have no idea how one can abuse a folderItem. I certainly 
>>deny I have ever done it. And rumors to the contrary are not 
>>sufficient to convict. At least not again.
>
>I am not trying to convict anyone, just trying to point out what I 
>would consider workflow flaw.

That was joke.

>
>>
>>There is a bug in RB that causes problems in the following scenario:
>>
>>1. Use GetSaveFolderItem to make a folderItem (f) -- it must 
>>replace an existing file
>
>FolderItems don't replace anything. It might point to an existing 
>file, but it doesn't actually do anything until you call a method on 
>the file. So here you have a folderitem that points to an existing 
>file.
>
>>2. db.Create(f...)
>
>Now you ask Valentina to create a database at a location that is 
>occupied by an existing file. To my mind this is a silent error. 
>What happens in an app where a user makes a mistake, or it's a 
>simple programming error, and Valentina silently replaces a file I 
>wanted?
>
>This is why I think it's an abuse. Valentina should not replace an 
>existing file IMO. It should expect the programmer to provide a 
>location where a file doesn't exist so that it can create a new one 
>there without stomping on the other file.
>
>Of course this is just my opinion, but we can't properly deal with 
>the scenario if we don't know about it and for Valentina to silently 
>replace the file seems counter to what the create statement's 
>original intention was. Create a new file, not delete an existing 
>one.
>
>I appreciate the clarification, and at least now I know to watch out for it.
>

Kevin, do you use RB? I ask because if you do you should know that 
GetSaveFolderItem (see above) is a standard method for obtaining a 
folderItem prior to saving a file to disk:

f = GetSaveFolderItem("", "database1")

It puts up a standard "Save As" dialog box.

If you click Save and the file already exists, you are asked if you 
want to replace it with a new file. You can cancel or proceed. If you 
proceed, a folderItem is created. Valentina hasn't yet entered the 
picture.

You pass this folderItem to Valentina in db.create(f...). Valentina 
overwrites the existing file. This triggers the bug.

Jon


More information about the Valentina-beta mailing list