Kelson has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/296931 )
Change subject: Fix issue #2 Zimdump crashes on long titles.
......................................................................
Fix issue #2 Zimdump crashes on long titles.
Most of filesystems have a filename limited to 255 bytes.
If the filename is > 255 bytes truncate it.
Postfix the truncated filename with a counter to avoid name collision.
Change-Id: I0475aaa2d1221be46c48c5a52814ca6659cc7940
---
M zimlib/src/tools/zimDump.cpp
1 file changed, 8 insertions(+), 0 deletions(-)
Approvals:
Kelson: Verified; Looks good to me, approved
diff --git a/zimlib/src/tools/zimDump.cpp b/zimlib/src/tools/zimDump.cpp
index 65d13b8..7c0149d 100644
--- a/zimlib/src/tools/zimDump.cpp
+++ b/zimlib/src/tools/zimDump.cpp
@@ -394,6 +394,7 @@
void ZimDumper::dumpFiles(const std::string& directory)
{
+ unsigned int truncatedFiles = 0;
::mkdir(directory.c_str(), 0777);
std::set<char> ns;
@@ -406,6 +407,13 @@
std::string::size_type p;
while ((p = t.find('/')) != std::string::npos)
t.replace(p, 1, "%2f");
+ if ( t.length() > 255 )
+ {
+ std::ostringstream sspostfix, sst;
+ sspostfix << (++truncatedFiles);
+ sst << t.substr(0, 254-sspostfix.tellp()) << "~" << sspostfix.str();
+ t = sst.str();
+ }
std::string f = d + '/' + t;
std::ofstream out(f.c_str());
out << it->getData();
--
To view, visit https://gerrit.wikimedia.org/r/296931
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0475aaa2d1221be46c48c5a52814ca6659cc7940
Gerrit-PatchSet: 1
Gerrit-Project: openzim
Gerrit-Branch: master
Gerrit-Owner: Mgautierfr <[email protected]>
Gerrit-Reviewer: Kelson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits