[Bug] Folder arguments with a trailing slash break the PBO export
Describe the bug Launching PboViewer via command line using a path to a mission folder as argument is bugged. This is a twofold issue:
- when the mission folder path doesn't end with a slash, PboViewer opens with an empty GUI, seemingly ignoring the folder path argument (minor nuisance, but not catastrophic)
- when the mission folder path ends with a slash, PboViewer opens the folder properly, but exporting the folder yields a broken .pbo file (missing files/folders, and the first character is trimmed). PboViewer is effectively unuseable when launched this way.
To Reproduce Steps to reproduce the behavior: 1. Download the attached test mission archive and extract it somewhere (in this example, next to PboViewer) 2. Start your terminal and launch PboViewer with the folder path as argument:
./PboViewer "Test.Altis"
3. Observe that PboViewer starts with an empty GUI:
4. Close PboViewer
5. In the terminal, launch PboViewer with the same folder path as argument, but add a trailing slash at the end:
./PboViewer "Test.Altis/"
Observe that PboViewer now opens the folder in the GUI:
6. Click "Pack the folder to PBO"
7. Notice that the file name field is empty (it isn't when manually opening a folder in PboViewer and packing to PBO)
8. Enter a name and hit "Save"
9. Close PboViewer
10. Open the exported mission PBO file with PboViewer (not necessarily using the command line this time, though it shouldn't make a difference)
11. Notice that the PBO contains files with incorrect names (first character is trimmed), and contains garbled data (some files are empty, others contain binary data, yet all files were originally text files)
Expected behavior
- Trailing slashes, or the absence thereof, should not have an impact on the behaviour of the program (consistency)
- PboViewer should suggest the name of the opened folder when exporting to a PBO
- Exporting to a PBO shouldn't break files (obviously :stuck_out_tongue:)
Screenshots
Overview of the test mission folder:
Operating system Arch Linux 6.9.8-arch1-1
Additional context Test mission archive: Test.Altis.tar.gz
Exported PBO file (renamed to .zip to allow uploading):
Test.Altis.pbo.zip
Hello, sorry for the long reply, that is an interesting bug. I will check on my side. I suspect it comes from the PBO library implementation. I will check that asap.
I fix it by removing the trailing slash (it is not perfect, but it works at least). Currently, the application needs to be redone since the version of Avalonia I used is obsolete. Can you confirm that the fix works with this new build? Link of the new build (I cannot upload file other 25 MB) : https://we.tl/t-NtfjNshxgs
I'm sorry, but publishing new files via an external webhost feels a bit odd. I can't even see the sources to that file.
As for removing the trailing slash: does this mean the program now trims the trailing slash of the parameter? Because if so, that would yield the same result as described in point .2 of my original post, and cause the GUI to launch with an empty view (which is the first half of my issue). It would certainly stop me from accidentally building a broken PBO, but I can already achieve that by trimming the trailing slash on my end (e.g. via bash scripts).
EDIT: I hope this didn't come across as hash or dismissive; I appreciate your effort in investigating and fixing this issue. What I meant is I can live with the current version, and I'm also fine with waiting for a future release if it involves a partial or even full rewrite of the application. As for your new build, I've simply had bad experience with externally hosted files in the past, so even though your argument about file size may be valid, I will have to go with the safe option.
I also added the detection if the given path is a directory. On my testing it works great, but I want you to test before since I use Windows and not Linux. Instead of the file transfer, here is the pre-release based on this issue branch : https://github.com/SteezCram/PboViewer/releases/tag/v1.4.2b
If you have a bug, and you create an issue, I will try to solve it 😄. I want this project to help the community.
I stand corrected regarding the fix causing the issue of point .2. It appears to work correctly now - I am no longer able to create corrupted PBOs (even if I add multiple trailing slashes). Thank you! :+1:
Does this also fix the problem with the empty view also?
Yes, forgot to mention - that bug appears to be fixed too now. 🙂
Going to close this, as both of my issues are now resolved.