]> pd.if.org Git - zpackage/commitdiff
improve error handling in zpm-addfile
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 17 Sep 2016 07:03:42 +0000 (02:03 -0500)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 17 Sep 2016 07:22:45 +0000 (02:22 -0500)
zpm-addfile.c

index 961b6b806876a5fdff4bd0996264668df5877b6e..480c38a044314b7fc27887811779c3e11942ffcf 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdlib.h>
 #include <stdio.h>
 #include "zpm.h"
 
@@ -11,10 +12,13 @@ int main(int ac, char **av){
        }
        zpm_open(&pkg, av[1]);
        zpm_begin(&pkg);
-       zpm_import(&pkg, av[2], 0, hash);
-       zpm_commit(&pkg);
+       if (zpm_import(&pkg, av[2], 0, hash)) {
+               zpm_commit(&pkg);
+               fprintf(stdout, "%s\n", hash);
+               //fprintf(stdout, "%s %s\n", hash, av[2]);
+       } else {
+               exit(1);
+       }
        zpm_close(&pkg);
-       //fprintf(stdout, "%s %s\n", hash, av[2]);
-       fprintf(stdout, "%s\n", hash);
        return 0;
 }