2021-02-25 23:54 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0006376Spring engineLuapublic2020-07-04 17:08
ReporterSanguinario_Joe 
Assigned Togajop 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version104.0 +git 
Target VersionFixed in Version 
Summary0006376: Impossible to map (VFS.MapArchive) archives inside subfolders
DescriptionVFS.MapArchive starts with the following code chunk:

===
    const std::string& filename = archiveScanner->ArchiveFromName(luaL_checkstring(L, 1));

    // the path may point to a file or dir outside of any data-dir
    if (!LuaIO::IsSimplePath(filename))
        return 0;

    if (!CFileHandler::FileExists(filename, SPRING_VFS_RAW)) {
        std::ostringstream buf;
        buf << "[" << __func__ << "] archive not found: " << filename;

        lua_pushboolean(L, false);
        lua_pushsstring(L, buf.str());
        return 2;
    }
===

However, if the provided file name in luaL_checkstring(L, 1) is a map (which is therefore inside maps subfolder), then archiveScanner->ArchiveFromName will return the filename, without the subfolder prefix, so CFileHandler::FileExists will inexorably fail...
Steps To ReproduceCreate a dumb widget which is just simply mapping a file, and check the returned boolean variable and error string.
Additional Information---

I tried replacing all the code chunk above by the following:

const std::string& filename = luaL_checkstring(L, 1);

and it worked just fine. I would say vfsHandler->AddArchive is robust enough to can avoid all those checks before, but I'm not that sure, so I submit an issue rather than a PR.

---

I checked it is failing in maintenance, no idea about develop

---

Apparently VFS.UnmapArchive is working fine

---

I'm afraid VFS.UseArchive is affected by similar inconsistencies, since it calls to CFileHandler::FileExists with the filename instead of the filepath
TagsNo tags attached.
Checked infolog.txt for ErrorsYes
Attached Files

-Relationships
+Relationships

-Notes

~0020377

Sanguinario_Joe (reporter)

I created PRs for both maintenance and develop:

https://github.com/spring/spring/pull/510
https://github.com/spring/spring/pull/509
+Notes

-Issue History
Date Modified Username Field Change
2020-03-30 19:42 Sanguinario_Joe New Issue
2020-04-02 19:06 Sanguinario_Joe Note Added: 0020377
2020-07-04 17:08 Kloot Assigned To => gajop
2020-07-04 17:08 Kloot Status new => resolved
2020-07-04 17:08 Kloot Resolution open => fixed
+Issue History