B4J Question Archiver Lib - has a handle to file - can not delete...

Harris

Expert
Licensed User
Longtime User
The sub below is the event raised when Archiver trys to unzip a file.
It seems that it detected a zip with an issue, could not unzip it - then it could not delete it - like the archiver still had a handle on it.
Log(" --- file did not pass unzip - delete it if we can: " & currdel)
delzip(currdel)

However - I looked at the file in question and it was perfectly vaid - unzipped just fine - and contents were in perfect order too.... aaarrrrgggg!
Since this ONE file kept hanging (could not delete it) - no other files (over 1800 of them) could not get processed.
I go to look at data - and it's not there - cause the files didn't get unzipped.

Anyone else have this issue - or suggestions on how to handle this problem? (move , rename, pull hair out even more?)...

Thx

EDIT:
Just recently (minutes ago) I found where archiver successfully unzipped the file, moved contents to desired folder - BUT COULD NOT DELETE IT!
Now the process go around in a loop - processing the same file since it still exists...
One thing I am trying is to Dim Archiver in the Globals - rather than each time in the sub...

If I close my app and restart it - the offending files get deleted properly - indicating to me that something had a hold (lock) on them....

End EDIT..


B4X:
Sub unzip_UnZipDone( err As Boolean, no As Int)
    ' handle file if needed
    Log(ABMShared.CurrDT& " Unzipdone - completed without error? "&err& "   num files:"&no     )
    If err = False Then
        Log("  --- file did not pass unzip - delete it if we can: " & currdel)
        delzip(currdel)
        Return
    End If
    
    Wait For (File.CopyAsync(ecmFolder1,currdel,base_ecm&"/hist",currdel)) Complete (Success As Boolean)
    'Log("file copy to hist Success: " & Success)
    If Success Then
        Log("  --- Did copy file to hist: " & currdel)
    Else
        Log("  --- Did not copy file due to copy failure: " & currdel)
    End If
    
    delzip(currdel)
    
End Sub
 

Harris

Expert
Licensed User
Longtime User
Good idea @agraham .
I shall give it a go.

I am using AsyncUnZip (runs in own thread) to handle process.
Also, I add problem files to a list and exit the loop if all it is doing is hammering locked files.
This also allows it to proceed to the next file, instead of repeating on the same problem child.
I shall report back if anything changes for the good...

Thanks
B4X:
            If arc.IsValidZipFile( ecmFolder1&"/"& str) Then
                Log("   --- "&str&" is VALID zip")
                ' could not use ArchiverPlusZip UnZip...  generated error looking for DoEvents!!!!!
                'arc.UnZip(File.Combine( ecmFolder1,str), File.Combine(  ecmFolder,newfld), "Archiver" )
                Dim df As Int
                df = deadfiles.IndexOf( currdel )
                If (df = -1) Then
                  arc1.AsyncUnZip(ecmFolder1, str, ecmFolder&"/"&newfld, "unzip")
                
                Else
                    delzip(currdel)
                End If
                
            Else
                Log("   --- "& str&" is NOT VALID zip")
                delzip(str)   
            End If
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Seems better now. However, there has not been many files pass through the system since Sleep was applied (maybe 30).
I shall keep watching.
Thx
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Seems better now. However, there has not been many files pass through the system since Sleep was applied (maybe 30).
I shall keep watching.
Thx

Spoke too soon, unfortuantely...
Here we have an example of 2 locked files that can't get deleted programatically or using File Explorer.

The only way is to shut down my app on the server to release the handle (that something has on it) - then they can be deleted...
Obviously, shutting down the server app it not practical or desirable.

Thanks


1669702303260.png
 
Upvote 0
Top