{
struct lxc_container *c1;
struct stat fbuf;
+ bool bret = false;
char path[MAXPATHLEN];
char *buf = NULL;
char *lxcpath = NULL;
if (!(lxcname = strtok_r(NULL, "\n", &scratch)))
break;
c1 = lxc_container_new(lxcname, lxcpath);
- if (!c1)
- goto next;
+ if (!c1) {
+ counter++;
+ continue;
+ }
if (!c1->destroy(c1)) {
fprintf(stderr, "Destroying snapshot %s of %s failed\n", lxcname, my_args.name);
lxc_container_put(c1);
return -1;
}
lxc_container_put(c1);
-next:
counter++;
}
free(buf);
ret = snprintf(path, MAXPATHLEN, "%s/%s/snaps", c->config_path, c->name);
if (ret < 0 || ret >= MAXPATHLEN)
return -1;
- if (dir_exists(path)) {
- if (!c->destroy_with_snapshots(c)) {
- fprintf(stderr, "Destroying %s failed\n", my_args.name);
- return -1;
- }
- } else {
- if (!c->destroy(c)) {
- fprintf(stderr, "Destroying %s failed\n", my_args.name);
- return -1;
- }
+
+ if (dir_exists(path))
+ bret = c->destroy_with_snapshots(c);
+ else
+ bret = c->destroy(c);
+
+ if (!bret) {
+ fprintf(stderr, "Destroying %s failed\n", my_args.name);
+ return -1;
}
printf("Destroyed container %s including snapshots \n", my_args.name);