New topic: 

Weird problem: backing up some folders causes IO Errors?

<http://forums.realsoftware.com/viewtopic.php?t=45757>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        rebrandsoftware          Post subject: Weird problem: backing up 
some folders causes IO Errors?Posted: Mon Oct 29, 2012 2:58 pm                  
       
Joined: Wed Mar 25, 2009 4:30 pm
Posts: 244
Location: Alexandria, VA, USA                Hi Everyone,

I have a strange problem and I'm completely stumped.

I have a backup program that I'm running into problems with.  Here is what 
happens:

1) I add my "Development" folder to be backed up.  This is a folder within my 
home directory that contains 34 subfolders with about 4500 files in total.
2) The folder is searched, all subfolders and files within are added to a list 
of files to back up
3) Immediately, before copying any files to the backup location, I receive IO 
errors when trying to open a binary stream to copy the first file.  The path is 
correct, the file exists, it's not open in any application.
4) Thereafter, I receive the error "Could not connect to database" if I try to 
call database.open

It's as if suddenly I am not allowed to create any file connections, not to the 
files I'm trying to back up and not to the database.

I thought there might be a problem with a file in one of the folders, so I 
tried this:

1) Individually add all the subfolders and files within the "Development" 
folder (avoiding the search which started at the parent folder)
2) All folders and files are recursively searched
3) The files are then copied properly
4) The connection to the database works

So is there something about searching the Development folder as the top parent 
that is causing all these IO Errors and the inability to connect to the 
database?  Why wouldn't the same error be caused by searching each of the 
children folders individually?  It's exactly the same fileset.

I thought that the problem might be too many open DB connections, so I went 
through and make sure all the recordsets and databases were closed and set to 
nil.  It didn't make any difference.

Any ideas about what could be going wrong?  Below is some of the code.

Thanks!

-Mike

redim mFileSearch(-1)
redim mSearchFolders(0)
mSearchFolders(0) = f

for iFolders = 0 to ubound(mSearchFolders)
  'search with wildcards entered by user
  b = NonRecursiveSearch(mSearchFolders(iFolders), cf.Include, cf.Exclude)
next

for j = 0 to ubound(mFileSearch)
  c.AddBackupFile(mFileSearch(j))
  sStatus = getCaption("MSG_ADDING") + ": " + mFileSearch(j).Name + " (" + 
cstr(ubound(c.aFilesBackup) + 1) + ")"
next

Function NonRecursiveSearch(theItem as FolderItem, optional sMatch as string = 
"*.*", optional sExclude as string = "", optional bHidden as boolean = false) 
As boolean
  dim mItemCount, thisItem as Integer
  dim currentItem as FolderItem
  dim sFile, sExt as string
  dim a() as string
  dim b as boolean
  
  
  app.YieldToNextThread
  
  mRecursiveItemCount = mRecursiveItemCount + theItem.count //counts the item 
in the folder
  
  for thisItem = 1 to theItem.count
  currentItem = theItem.trueItem(thisItem) // get the next item in the folder
  if currentitem <> nil AND currentItem.ExistsUNC = true then 
//NilObjectException Check
  if bHidden = true or (bHidden = false and currentitem.Visible = true) then
    if currentItem.Directory = true then
    // do something with the folder
    'b = RecursiveSearch(currentItem, sMatch, sExclude) // recursive call
    mSearchFolders.Append currentItem
    'recursion was causing problems so instead I just keep an array of all the 
folders and search them all
    else
    // do something with the file
    if matchFilePattern(currentItem, sMatch, true) = true and 
matchFilePattern(currentItem, sExclude, false) = true then
    'the file matches a search pattern entered by the user
    redim mFileSearch(ubound(mFileSearch) + 1)
    mFileSearch(ubound(mFileSearch)) = currentItem
    end if
    end if
  end if
  end if
  app.YieldToNextThread
  next
  
  return true
End Function
   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to