Skip to content

Commit

Permalink
implemented DELETE
Browse files Browse the repository at this point in the history
  • Loading branch information
nilclass committed Aug 1, 2013
1 parent ec537ac commit ccf7aab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ static struct fuse_operations rs_ops = {
.mkdir = rs_mkdir,
.rmdir = rs_rmdir,
.flush = rs_flush,
.create = rs_create
.create = rs_create,
.unlink = rs_unlink
};

static struct fuse_opt rs_opts[] = {
Expand Down
6 changes: 5 additions & 1 deletion src/operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ int rs_flush(const char *path, struct fuse_file_info *fi) {
return 0;
}

int rs_create (const char *path, mode_t mode, struct fuse_file_info *fi) {
int rs_create(const char *path, mode_t mode, struct fuse_file_info *fi) {
return rs_truncate(path, 0);
}

int rs_unlink(const char *path) {
return delete_node_remote(path);
}
9 changes: 7 additions & 2 deletions src/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ long perform_request(enum rs_method method, const char *path, struct rs_node* no
log_msg("PUTting %d bytes", node->size);
break;
case DELETE:
log_msg("DELETE NOT IMPLEMENTED!!!");
return -1;
curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, "DELETE");
break;
}

static char errorbuf[CURL_ERROR_SIZE];
Expand Down Expand Up @@ -197,3 +197,8 @@ int put_node_remote(const char *path, struct rs_node *node) {
long status = perform_request(PUT, path, node);
return (status == 200 || status == 201) ? 0 : status;
}

int delete_node_remote(const char *path) {
long status = perform_request(DELETE, path, NULL);
return status == 200 ? 0 : status;
}
4 changes: 3 additions & 1 deletion src/remotestorage-fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ int rs_write(const char *path, const char *buf, size_t size, off_t offset,
int rs_mkdir(const char *path, mode_t mode);
int rs_rmdir(const char *path);
int rs_flush(const char *path, struct fuse_file_info *fi);
int rs_create (const char *path, mode_t mode, struct fuse_file_info *fi);
int rs_create(const char *path, mode_t mode, struct fuse_file_info *fi);
int rs_unlink(const char *path);

/* clutter */

Expand Down Expand Up @@ -111,6 +112,7 @@ void cleanup_remote();
struct rs_node *get_node_remote(const char *path, bool fetch_body);
struct rs_node *get_node_remote_via_parent(const char *path, bool fetch_body);
int put_node_remote(const char *path, struct rs_node *node);
int delete_node_remote(const char *path);

/* TRIE */

Expand Down

0 comments on commit ccf7aab

Please sign in to comment.