matthiaskoenig / pymetadata

Python utilities for working with metadata and COMBINE archives
GNU Lesser General Public License v3.0
6 stars 3 forks source link

omex complains about missing files in archive #52

Open fbergmann opened 4 weeks ago

fbergmann commented 4 weeks ago

I've noticed that when importing a omex archive in pymetadata, that it complains on windows about entries missing in the manifest, even though they are present.

Looking through the code, this is due to

https://github.com/matthiaskoenig/pymetadata/blob/d09ca8976df1a896ed88d935d2d4391c66ee3170/src/pymetadata/omex.py#L576

which on windows will create a string with a backslash as separator, if the file in the manifest is encoded with a slash, then the entry will not be able to be properly resolved.

matthiaskoenig commented 4 weeks ago

@fbergmann Thanks for the report. I will fix this asap.

fbergmann commented 14 hours ago

thanks! locally i've solved it with just replacing the backslashes with forward ones and was able to get it running

       for root, _dirs, files in os.walk(str(directory)):
            for file in files:
                file_path = os.path.join(root, file)
                location = f"./{os.path.relpath(file_path, directory)}"
                if location == "./manifest.xml":
                    # manifest is created from the internal manifest entries
                    continue

                # replace backslashes with forward slashes  <--------
                location = location.replace("\\", "/")
                ...