[Fusionforge-commits] r15034 - trunk/src/www/docman

Franck VILLAUME nerville at fusionforge.org
Sun Jan 29 17:29:30 CET 2012


Author: nerville
Date: 2012-01-29 17:29:29 +0100 (Sun, 29 Jan 2012)
New Revision: 15034

Modified:
   trunk/src/www/docman/view.php
Log:
fix bug with download as zip feature: sometime returns empty zip file

Modified: trunk/src/www/docman/view.php
===================================================================
--- trunk/src/www/docman/view.php	2012-01-26 17:52:40 UTC (rev 15033)
+++ trunk/src/www/docman/view.php	2012-01-29 16:29:29 UTC (rev 15034)
@@ -184,7 +184,7 @@
 				$filename = 'docman-'.$g->getUnixName().'-'.$dg->getID().'.zip';
 				$file = forge_get_config('data_path').'/'.$filename;
 				$zip = new ZipArchive;
-				if ( !$zip->open($file, ZIPARCHIVE::OVERWRITE))
+				if ( !$zip->open($file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE))
 					exit_error(_('Unable to open zip archive for download as zip'), 'docman');
 
 				// ugly workaround to get the files at doc_group_id level
@@ -192,8 +192,8 @@
 				$docs = $df->getDocuments(1);	// no caching
 				if (is_array($docs) && count($docs) > 0) {	// this group has documents
 					foreach ($docs as $doc) {
-						if ( !$zip->addFromString($doc->getFileName(),$doc->getFileData()))
-							return false;
+						if (!$zip->addFromString($doc->getFileName(),$doc->getFileData()))
+							exit_error(_('Unable to fill zipfile.'), 'docman');
 					}
 				}
 				if ( !docman_fill_zip($zip, $nested_groups, $df, $dg->getID()))
@@ -223,7 +223,7 @@
 			$filename = 'docman-'.$g->getUnixName().'-selected-'.time().'.zip';
 			$file = forge_get_config('data_path').'/'.$filename;
 			$zip = new ZipArchive;
-			if ( !$zip->open($file, ZIPARCHIVE::OVERWRITE))
+			if (!$zip->open($file, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE))
 				exit_error(_('Unable to open zip archive for download as zip'), 'docman');
 
 			foreach($arr_fileid as $docid) {
@@ -235,8 +235,8 @@
 						exit_error($d->getErrorMessage(), 'docman');
 					}
 
-					if ( !$zip->addFromString($d->getFileName(),$d->getFileData()))
-						return false;
+					if (!$zip->addFromString($d->getFileName(), $d->getFileData()))
+						exit_error(_('Unable to fill zipfile.'), 'docman');
 				} else {
 					$zip->close();
 					unlink($file);




More information about the Fusionforge-commits mailing list