Skip to content

Commit 7278792

Browse files
committed
Fix undeploy
1 parent febcf54 commit 7278792

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

d.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,19 @@ int main(int argc, char *argv[]) {
160160
snprintf(destination_path, PATH_MAX, "%s", entry.destination);
161161
deploy(source_path, destination_path, debug);
162162
} else if (command == CommandUndeploy) {
163-
if (unlink(entry.destination) == -1) {
164-
perror("unlink");
165-
exit(1);
163+
char source_path[PATH_MAX];
164+
char destination_path[PATH_MAX];
165+
snprintf(source_path, PATH_MAX, "%s", entry.source);
166+
snprintf(destination_path, PATH_MAX, "%s", entry.destination);
167+
if (destination_path[strlen(destination_path) - 1] == '/') {
168+
destination_path[strlen(destination_path) - 1] = '\0';
169+
}
170+
if (unlink(destination_path) == -1) {
171+
if (errno != ENOENT) {
172+
fprintf(stderr, "Failed to unlink \"%s\"\n", destination_path);
173+
perror("unlink");
174+
exit(1);
175+
}
166176
}
167177
}
168178
}

0 commit comments

Comments
 (0)