SalesforceCommerceCloud / sfcc-ci

Salesforce Commerce Cloud CLI
https://npmjs.com/package/sfcc-ci
BSD 3-Clause "New" or "Revised" License
231 stars 93 forks source link

Problem when unzipping error 500, logs show "directory not empty" error for new codeversion #320

Closed irobotbfealy closed 2 years ago

irobotbfealy commented 2 years ago

Hello -- I'm uploading a zip file I created with my new build. I've got the file created with what appears to be the correct file/folder structure, and have it pulling in all the right cartridge folders etc... when I upload, I get an error 500 from sfcc-ci and the SF logs show me: ERROR WebDAVServlet|1016032764|Sites|-|/Sites/cartridges/20220801-DEV-149.zip com.demandware.beehive.core.capi.file.MultithreadingZipFileProcessor - - - - 527891683779082240 - Failed to process zip file [20220801-DEV-149.zip]. Stack trace <2fb9062c4e6528a43cdabdc5120ee0fd> java.util.concurrent.ExecutionException: java.nio.file.DirectoryNotEmptyException: /remote/bfxp_s/bfxp_s06/sharedata/cartridges/20220801-DEV-149/app_storefront_base/cartridge/client

There are files uploaded to that folder, but not all -- there's definitely a few folders at the client level I see in the zip that don't make it to the codeversion that's uploaded -- as a result, I can't get a functioning site deployed, I can activate but the site won't display and I get errors about a missing module 'server'

Any assistance is appreciated. Thank you.

clavery commented 2 years ago

@irobotbfealy This is strange and not really anything caused by sfcc-ci (because there's not much it can do about a 500 from the server).

I'm curious how you create this zip (i.e. the zip tool/commands you use). I have not seen issues when extracting zip files to existing directory structures in WebDAV so I'm wondering if there is something strange about the zip structure here that is is throwing off this MultithreadingZipFileProcessor.

irobotbfealy commented 2 years ago

@clavery I'm using a powershell script that is moving through our source tree after the build process completes and pulling in any folder (and all contents) if the parent folder contains a .project file, which appeared to be the method of choice and mimics what we'd seen in other places as the preferred way to create the file for upload -- the contents appeared to be the same as what was present on working versions of the site.

clavery commented 2 years ago

@irobotbfealy I'm curious are you using Compress-Archive in powershell to create the zip files? There's been a number of issues in the past with archives created using that that do not work properly on unix systems (this is older but googling can give you others https://github.com/PowerShell/PowerShell/issues/3590). That may be the source of the issue.

If you are using that and If there's a way to use a different archive utility to create it that may help. You may want to try and do this manually and create the same structure using one of those utilities. For instance see this answer where someone used 7zip to create https://superuser.com/a/1561753

My hunch is that certain directories are being extracted with improper permissions which is causing the extraction code at SFCC to fail fully extracting the file and leaving you with a skeleton of what you want.

irobotbfealy commented 2 years ago

@clavery I am using Compress-Archive -- and after changing over to the 7Zip Portable, it seems the zip file is now acceptable for the back end. That's something I most definitely would not have expected, thank you SO MUCH for the tip.

irobotbfealy commented 2 years ago

@clavery Thank you that solved the problem, I ended up changing over to 7Zip Portable edition and the zip now uploads and activates correctly. Many thanks for the pointer to this particular little bug!