1. Nop Version: 4.20
2. Other software: Windows 10, 7-Zip
3. Expected behavior: Plugin/theme zip file is uploaded into Nop and processed.
4. Actual behavior: Nop throws error "The archive should contain only one root plugin or theme directory. For example, Payments.PayPalDirect or DefaultClean. To upload multiple items, the archive should have the 'uploadedItems.json' file in the root" and the zip file cannot be uploaded.
5. Steps to reproduce:
- Copy the default template folder
- Zip the folder as it is by using the "Send to - Compressed (zipped) folder" within Windows.
- Upload the zip file and Nop will throw the error despite the theme folder structure is correct.
6. Details: After doing some research, I have found some discrepancies in the zip file structure that created by Windows and by other zip program and because of the logic that check for the root folder in the zip file within Nop, it will throws the error even though the folder layout is correct. If you compare the two zip files, one is created by the built-in Windows feature and one by other software (for example, I used 7-Zip and Winrar), the Window zip file is missing the name of the root folder in the first few bytes. Hence, during the uploading process, Nop will use this below code in UploadService.cs to check for root folder name and will throw the error because it is missing:
protected virtual IDescriptor UploadSingleItem(string archivePath)
// Other code
var rootDirectories = archive.Entries.Where(entry => entry.FullName.Count(ch => ch == '/') == 1 && entry.FullName.EndsWith("/")).ToList(); // Line 88
// Other code