airsdk / apm

AIR Package Manager
https://repository.airsdk.dev/
MIT License
60 stars 10 forks source link

Error extracting package on Windows #150

Closed mwelk closed 1 year ago

mwelk commented 2 years ago

Sometimes extracting the downloaded package fails on Windows with:

[2022-07-07T14:57:13.858Z] D::ExtractZipMacOSProcess::powershell version: 5.1.17763.1007
[2022-07-07T14:57:13.858Z] D::ProcessQueue::UNHANDLED PROCESS ERROR IN com.apm.client.processes.generic::ExtractZipProcess
[2022-07-07T14:57:13.858Z] E::ProcessQueue::Error #3012: Cannot delete file or directory.
[2022-07-07T14:57:13.858Z] E::ProcessQueue::Error: Error #3012: Cannot delete file or directory.
[2022-07-07T14:57:13.858Z]  at flash.filesystem::File/copyTo()
[2022-07-07T14:57:13.858Z]  at com.apm.client.processes.generic::ExtractZipWindowsProcess/start()
[2022-07-07T14:57:13.858Z]  at com.apm.client.processes.generic::ExtractZipProcess/start()
[2022-07-07T14:57:13.858Z]  at com.apm.client.processes::ProcessQueue/checkAndStartNextProcess()
[2022-07-07T14:57:13.858Z]  at com.apm.client.processes::ProcessQueue/process_eventHandler()
[2022-07-07T14:57:13.858Z]  at flash.events::EventDispatcher/dispatchEventFunction()
[2022-07-07T14:57:13.858Z]  at flash.events::EventDispatcher/dispatchEvent()
[2022-07-07T14:57:13.858Z]  at com.apm.client.processes::ProcessBase/complete()
[2022-07-07T14:57:13.858Z]  at com.apm.client.commands.packages.processes::DownloadPackageProcess/checkExistingFileComplete()
[2022-07-07T14:57:13.858Z]  at Function/DownloadPackageProcess.as$0:anonymous()
[2022-07-07T14:57:13.858Z]  at Function/DownloadPackageProcess.as$1:anonymous()
[2022-07-07T14:57:13.858Z]  at Function/Checksum.as$0:anonymous()
[2022-07-07T14:57:13.858Z]  at com.apm.client.processes::ProcessBase/complete()
[2022-07-07T14:57:13.858Z]  at com.apm.client.processes::ProcessBase/complete()
[2022-07-07T14:57:13.858Z]  at com.apm.client.processes.generic::ChecksumWindowsProcess/onExit()
[2022-07-07T14:57:13.858Z] V::ProcessQueue::process_eventHandler( process_failed )
[2022-07-07T14:57:13.858Z] ERROR :: Failed to install package : com.distriqt.facebook.Login@10.2.0
[2022-07-07T14:57:13.858Z] V::ProcessQueue::process_eventHandler( process_failed )
[2022-07-07T14:57:13.858Z] install :: Error #3012: Cannot delete file or directory.

I need to manually remove the previously extracted folder first for apm to continue.

Versions: AIR: 33.1.1.889 APM: 1.17 Windows: Windows Server 2019 Build 1809 PowerShell: 5.1.17763.1007

marchbold commented 2 years ago

What permissions are the directories being created with? Must be some issue there some where. I haven't tested this on a windows server machine before.

mwelk commented 2 years ago

Looks like it happens while trying to "rename" the package to a filename with .zip extension.

if (_zipFile.extension != "zip")
{
    // Powershell script can't handle non-zip extension archives so we copy to a .zip tmp file and delete after
    _zipFileRef = new File( _zipFile.nativePath + ".zip" );
    _zipFile.copyTo( _zipFileRef );
    _deleteAfter = true;
}

Btw. the ExtractZipWindowsProcessis logging as ExtractZipMacOSProcess;-)

marchbold commented 2 years ago

(Yeah I noticed that above will get that typo fixed)

Seems like an odd error message to occur on a copy operation. Could you try deleting your apm_packages and running it from a clean state. Just wondering if there is some directory named the same as the tmp zip file we are using.

mwelk commented 2 years ago

It is already sufficient to delete the present folder for the ane that should be extracted to fix the problem temporary. But the next time the package needs to be updated or after a clean build, it may fail again.

mwelk commented 1 year ago

I fixed that issue by adding the overwrite flag to true while copying the zip file.

if (_zipFile.extension != "zip")
{
    // Powershell script can't handle non-zip extension archives so we copy to a .zip tmp file and delete after
    _zipFileRef = new File( _zipFile.nativePath + ".zip" );
    _zipFile.copyTo( _zipFileRef, true);
    _deleteAfter = true;
}

It may happen that the zip file is still there if the previous build failed.

marchbold commented 1 year ago

Ah nice one, did you want to do a pr with the fix or happy for me to put it in?

mwelk commented 1 year ago

No, I'm happy if you do it :-)