This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, master has been updated
       via  3e979ad9a2ebfd28949a2813ee1629beeb4a1fe3 (commit)
      from  e4098acf28805ab4356dcf5d8f73df59e2df826f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=3e979ad9a2ebfd28949a2813ee1629beeb4a1fe3

commit 3e979ad9a2ebfd28949a2813ee1629beeb4a1fe3
Author: Franck Villaume <[email protected]>
Date:   Sun Mar 19 17:56:39 2017 +0100

    forge cli: implement retrieving data into a zip file

diff --git a/src/bin/forge b/src/bin/forge
index b71bede..2220233 100755
--- a/src/bin/forge
+++ b/src/bin/forge
@@ -84,6 +84,12 @@ class CliActions {
                                echo "Use: .../forge groupDump <groupid> 
[json|raw]\n";
                                echo "to dump a group.\n";
                                echo $dumpFormatInfo;
+                               break;
+                       case 'getZipDump':
+                               echo "Use: .../forge getDataDump file 
[json|raw]\n";
+                               echo "to generate a zip file that includes all 
data based on parameter file.\n";
+                               echo "The file can be generated by using other 
Dump functions such as groupDump.\n";
+                               break;
                        default:
                                echo "Usage: .../forge ($methods) 
[arguments...]\n" ;
                                echo "Get more info use: .../forge help help\n";
@@ -104,6 +110,47 @@ class CliActions {
                $pm->deactivate($name);
        }
 
+       function getZipDump($file, $format = 'json') {
+               if (!is_file($file)) {
+                       echo _('Unable to load file')._(': ').$file;
+                       return false;
+               }
+               if (!in_array($format, array('json', 'raw'))) {
+                       echo _('Wrong file format')._('? ').$format;
+                       return false;
+               }
+               $stream_ori = file_get_contents($file);
+               if ($format == 'json') {
+                       $stream = json_decode($stream_ori, true);
+               } else {
+                       $stream = $stream_ori;
+               }
+               unset($stream_ori);
+               $time = time();
+               $zipfile = 'fusionforge-zipDump-'.$time.'.zip';
+               global $zip;
+               $zip = new ZipArchive();
+               if($zip->open($zipfile, ZIPARCHIVE::CREATE | 
ZIPARCHIVE::OVERWRITE) !== true) {
+                       echo _('Unable to create zip file')._(': ').$zipfile;
+                       return false;
+               }
+
+               function copyStorageRef($value, $key) {
+                       global $zip;
+                       if ($key == 'storageref' && $value != null) {
+                               if (is_file($value) && is_readable($value)) {
+                                       $localname = 
str_replace(forge_get_config('data_path').'/', '', $value);
+                                       $zip->addFile($value, $localname);
+                               }
+                       }
+               }
+
+               array_walk_recursive($stream, 'copyStorageRef');
+               $zip->addFile($file, basename($file));
+               $zip->close();
+               return file_exists($zipfile);
+       }
+
        function artifactDump($aid, $format = 'json') {
                $artifactDump['id'] = $aid;
                $artf = artifact_get_object($aid);

-----------------------------------------------------------------------

Summary of changes:
 src/bin/forge | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)


hooks/post-receive
-- 
FusionForge

_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits

Reply via email to