realbasic-betas.mbox
[Top] [All Lists]

Re: folderItem.count delayed

To: REALbasic Betas <realbasic-betas at lists dot realsoftware dot com>
Subject: Re: folderItem.count delayed
From: john roberts <jarobe01 at athena dot louisville dot edu>
Date: Thu, 27 Feb 2003 23:16:39 -0500
on 2/27/03 7:39 PM, Eric Harris-Braun at eric at glassbead dot com wrote:

>> I believe that's one of those great "features" of OS X, made by
>> many programmers that don't have a clue (who came apparently
>> from NeXT, not Apple). At least that's the effect that you get
>> from the new Finder. I thought (hoped) it would only happen in the
>> Finder but your finding suggest that it's even worse, unless RS
>> has implemented a new (not properly working) caching to speed up
>> FolderItem (which, as I've pointed out before, is awfully wasteful
>> timewise when you make repeated inquiries to the same FolderItem
>> object)

I think caching is a definite possibility. See below.
> 
> No, I think this is probably an RB bug, because if you delete a file
> instead of creating a new one, the count is updated right away!
> 
Careful.

The following is a slight modification of the original code presented by
Eric:

  dim f,fnew As FolderItem
  dim before_count,after_count As Integer
  dim b As BinaryStream
  
  f = getFolderItem("someFolder")
  if not f.exists then
    f.createAsFolder
  end
  before_count = f.count
  fnew = f.child("test")
  b = fnew.createBinaryFile("text")
  //f = getFolderItem("someFolder")//  <- *
  after_count = f.count
  if after_count = before_count then
    msgBox "Whoa!"
  else
    MsgBox "ok"
  end
  
As shown above, this generates the "Whoa" as noted by Eric. If the commented
line noted by * is uncommented, "ok" occurs.

Similarly, the following deletion will generate "Whoa"

  dim f,fnew As FolderItem
  dim before_count,after_count As Integer
  
  f = getFolderItem("someFolder")
  before_count = f.count
  fnew = f.child("test")
  fnew.Delete
  //f = getFolderItem("someFolder")//  <- **
  after_count = f.count
  if after_count = before_count then
    msgBox "Whoa!"
  else
    MsgBox "ok"
  end
 
while uncommenting  ** will generate "ok".

This is on classic (8.6 in particular).

John Roberts


---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>

Unsubscribe:
<mailto:realbasic-betas-off at lists dot realsoftware dot com>

Subscribe to the digest:
<mailto:realbasic-betas-digest at lists dot realsoftware dot com>
.


<Prev in Thread] Current Thread [Next in Thread>