[mapguide-commits] r9449 - sandbox/jng/deprecate_dwf/Server/src/Services/Resource
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jan 9 14:25:21 PST 2019
Author: jng
Date: 2019-01-09 14:25:21 -0800 (Wed, 09 Jan 2019)
New Revision: 9449
Modified:
sandbox/jng/deprecate_dwf/Server/src/Services/Resource/ZipFileReader.cpp
sandbox/jng/deprecate_dwf/Server/src/Services/Resource/ZipFileWriter.cpp
Log:
Fix improper close call on zip reader/writer that caused the zip file handles to remain open, causing the package tests to fail. Throw exceptions where appropriate.
Modified: sandbox/jng/deprecate_dwf/Server/src/Services/Resource/ZipFileReader.cpp
===================================================================
--- sandbox/jng/deprecate_dwf/Server/src/Services/Resource/ZipFileReader.cpp 2019-01-07 11:42:08 UTC (rev 9448)
+++ sandbox/jng/deprecate_dwf/Server/src/Services/Resource/ZipFileReader.cpp 2019-01-09 22:25:21 UTC (rev 9449)
@@ -84,7 +84,13 @@
{
if (m_unzip)
{
- unzCloseCurrentFile(m_unzip);
+ int r = unzClose(m_unzip);
+#ifdef _DEBUG
+ if (r != UNZ_OK)
+ {
+ throw new MgInvalidDwfPackageException(L"MgZipFileReader.~MgZipFileReader", __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+#endif
}
}
@@ -106,7 +112,7 @@
{
MgStringCollection arguments;
arguments.Add(filePath);
- throw new MgInvalidDwfPackageException(L"MgZipFileReader.MgZipFileReader", __LINE__, __WFILE__, &arguments, L"", NULL);
+ throw new MgInvalidDwfPackageException(L"MgZipFileReader.ExtractArchive", __LINE__, __WFILE__, &arguments, L"", NULL);
}
int err = UNZ_OK;
@@ -116,7 +122,7 @@
{
MgStringCollection arguments;
arguments.Add(filePath);
- throw new MgInvalidDwfPackageException(L"MgZipFileReader.MgZipFileReader", __LINE__, __WFILE__, &arguments, L"", NULL);
+ throw new MgInvalidDwfPackageException(L"MgZipFileReader.ExtractArchive", __LINE__, __WFILE__, &arguments, L"", NULL);
}
MgByteSourceUnzipImpl* impl = new MgByteSourceUnzipImpl(file_info, m_unzip);
Modified: sandbox/jng/deprecate_dwf/Server/src/Services/Resource/ZipFileWriter.cpp
===================================================================
--- sandbox/jng/deprecate_dwf/Server/src/Services/Resource/ZipFileWriter.cpp 2019-01-07 11:42:08 UTC (rev 9448)
+++ sandbox/jng/deprecate_dwf/Server/src/Services/Resource/ZipFileWriter.cpp 2019-01-09 22:25:21 UTC (rev 9449)
@@ -92,7 +92,7 @@
m_zip = zipOpen(mbFilePath.c_str(), 0);
if (!m_zip)
{
- //throw
+ throw new MgInvalidDwfPackageException(L"MgZipFileWriter.MgZipFileWriter", __LINE__, __WFILE__, NULL, L"", NULL);
}
}
@@ -102,6 +102,16 @@
///
MgZipFileWriter::~MgZipFileWriter()
{
+ if (m_zip)
+ {
+ int r = zipClose(m_zip, "Created by MapGuide Server"); //NOXLATE
+#ifdef _DEBUG
+ if (r != ZIP_OK)
+ {
+ throw new MgInvalidDwfPackageException(L"MgZipFileWriter.~MgZipFileWriter", __LINE__, __WFILE__, NULL, L"", NULL);
+ }
+#endif
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -146,7 +156,7 @@
if (err != ZIP_OK)
{
- //throw
+ throw new MgInvalidDwfPackageException(L"MgZipFileWriter.AddArchive", __LINE__, __WFILE__, NULL, L"", NULL);
}
const INT32 length = 4096;
@@ -158,7 +168,7 @@
err = zipWriteInFileInZip(m_zip, buffer, numBytes);
if (err < 0)
{
- //throw
+ throw new MgInvalidDwfPackageException(L"MgZipFileWriter.AddArchive", __LINE__, __WFILE__, NULL, L"", NULL);
}
} while ((err == ZIP_OK) && (numBytes > 0));
@@ -165,7 +175,7 @@
err = zipCloseFileInZip(m_zip);
if (err != ZIP_OK)
{
- //throw
+ throw new MgInvalidDwfPackageException(L"MgZipFileWriter.AddArchive", __LINE__, __WFILE__, NULL, L"", NULL);
}
MG_RESOURCE_SERVICE_CATCH(L"MgZipFileWriter.AddArchive")
@@ -173,33 +183,6 @@
delete[] mbFilePath;
MG_RESOURCE_SERVICE_THROW()
-
- /*
- DWFOutputStream* outputStream = NULL;
-
- MG_RESOURCE_SERVICE_TRY()
-
- CHECKARGUMENTNULL(byteReader, L"MgZipFileWriter.AddArchive");
-
- DWFString archivedFile(filePath.c_str());
- outputStream = m_zipFileDescriptor->zip(archivedFile);
-
- const INT32 length = 4096;
- BYTE buffer[length] = {0};
- INT32 numBytes = 0;
-
- do
- {
- numBytes = byteReader->Read(buffer, length);
- outputStream->write((const void*)buffer, (size_t)numBytes);
- } while (numBytes > 0);
-
- MG_RESOURCE_SERVICE_CATCH(L"MgZipFileWriter.AddArchive")
-
- DWFCORE_FREE_OBJECT(outputStream);
-
- MG_RESOURCE_SERVICE_THROW()
- */
}
///////////////////////////////////////////////////////////////////////////////
More information about the mapguide-commits
mailing list