]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/SVNReportParser.cxx
Reset: allow re-init of Nasal Ghosts.
[simgear.git] / simgear / io / SVNReportParser.cxx
index 758dd00dc0176335ac103656d9501cd39e52b2c7..b7f99d248fd369b29de21f26da5507b073b47a73 100644 (file)
@@ -165,7 +165,7 @@ namespace {
          _ptr = p;
      }
   
-    bool apply(std::vector<char>& output, std::istream& source)
+    bool apply(std::vector<unsigned char>& output, std::istream& source)
     {
         unsigned char* pEnd = _ptr + instructionLength;
         unsigned char* newData = pEnd;
@@ -330,11 +330,12 @@ public:
   }
   
   bool decodeTextDelta(const SGPath& outputPath)
-  {    
-    string decoded = strutils::decodeBase64(txDeltaData);
+  {
+      std::vector<unsigned char> output, decoded;
+    strutils::decodeBase64(txDeltaData, decoded);
     size_t bytesToDecode = decoded.size();
-    std::vector<char> output;      
-    unsigned char* p = (unsigned char*) decoded.data();
+         
+    unsigned char* p = decoded.data();
     if (memcmp(p, "SVN\0", DELTA_HEADER_SIZE) != 0) {
         return false; // bad header
     }
@@ -346,9 +347,9 @@ public:
     
     while (bytesToDecode > 0) {  
         if (!SVNDeltaWindow::isWindowComplete(p, bytesToDecode)) {
-         SG_LOG(SG_IO, SG_WARN, "SVN txdelta broken window");
-         return false;
-       }
+            SG_LOG(SG_IO, SG_WARN, "SVN txdelta broken window");
+            return false;
+        }
        
         SVNDeltaWindow window(p);      
         assert(bytesToDecode >= window.size());
@@ -362,7 +363,7 @@ public:
     std::ofstream f;
     f.open(outputPath.c_str(), 
       std::ios::out | std::ios::trunc | std::ios::binary);
-    f.write(output.data(), output.size());
+    f.write((char*) output.data(), output.size());
 
     // compute MD5 while we have the file in memory
     memset(&md5Context, 0, sizeof(SG_MD5_CTX));
@@ -391,7 +392,11 @@ public:
       finishFile(currentDir->addChildFile(currentPath.file()));
     } else if (!strcmp(name, SVN_OPEN_FILE_TAG)) {
       DAVResource* res = currentDir->collection()->childWithName(currentPath.file());   
-      assert(res);
+        if (!res) {
+            SG_LOG(SG_IO, SG_WARN, "SVN open-file: unknown: " << currentPath);
+            fail(SVNRepository::SVN_ERROR_IO);
+            return;
+        }
       finishFile(res);
     } else if (!strcmp(name, SVN_ADD_DIRECTORY_TAG)) {
       // pop directory
@@ -412,15 +417,16 @@ public:
     } else if (!strcmp(name, SVN_DAV_MD5_CHECKSUM)) {
       // validate against (presumably) just written file
       if (decodedFileMd5 != md5Sum) {
+          SG_LOG(SG_GENERAL, SG_INFO, "checksum fail on:" << currentPath);
         fail(SVNRepository::SVN_ERROR_CHECKSUM);
       }
     } else if (!strcmp(name, SVN_OPEN_DIRECTORY_TAG)) {
+        currentDir->updateReportComplete();
         if (currentDir->parent()) {   
           // pop the collection stack
           currentDir = currentDir->parent();
         }
         
-        currentDir->updateReportComplete();
         currentPath = currentDir->fsPath();
     } else {
     //  std::cout << "element:" << name;