Skip to content

Commit 0a8adfb

Browse files
committed
fix rm ./
1 parent 6fb3fb2 commit 0a8adfb

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

bin/cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ int resolve_rm(const char* cmd_path, int abs_flag, MYSQL* conn, const char* user
365365
if (res == NULL)
366366
{
367367
//delete account
368-
if (strcmp(cmd_path, "/") == 0)
368+
if (strcmp(cmd_path, "/") == 0 || strcmp(cmd_path, "./") == 0)
369369
{
370370
ret = sql_delete_user(conn, user_name);
371371
if (ret)
@@ -387,7 +387,7 @@ int resolve_rm(const char* cmd_path, int abs_flag, MYSQL* conn, const char* user
387387
}
388388
mysql_free_result(res);
389389
//delete account
390-
if (strcmp(cmd_path, "/") == 0)
390+
if (strcmp(cmd_path, "/") == 0 || strcmp(cmd_path, "./") == 0)
391391
{
392392
ret = sql_delete_user(conn, user_name);
393393
if (ret)

bin/sql.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,27 +116,24 @@ int sql_insert_file(MYSQL* conn, const char* user_name, const char* dir_id, int
116116
MYSQL_ROW row;
117117
char file_path[RESULT_LEN];
118118

119-
printf("filename=%s\n",file_name);
120-
char filename[RESULT_LEN];
121-
sprintf(filename, "%s", file_name);
122119
res = sql_select(conn, "file", "id", dir_id, 0);
123120
if (res == NULL)
124121
{
125122
return -1;
126123
}
127124
row = mysql_fetch_row(res);
128125
mysql_free_result(res);
129-
sprintf(file_path, "%s/%s", row[5], filename);
126+
sprintf(file_path, "%s/%s", row[5], file_name);
130127

131128
if (type == 0)
132129
{
133130
sprintf(query, "INSERT INTO file VALUES (default, %s, %d, '%s', NULL, '%s', NULL, default)",
134-
dir_id, type, filename, file_path);
131+
dir_id, type, file_name, file_path);
135132
}
136133
else
137134
{
138135
sprintf(query, "INSERT INTO file VALUES (default, %s, %d, '%s', %d, '%s', '%s', default)",
139-
dir_id, type, filename, file_size, file_path, file_md5);
136+
dir_id, type, file_name, file_size, file_path, file_md5);
140137
}
141138
#ifdef _DEBUG
142139
printf("sql: %s\n", query);

bin/transmission.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ int recv_file(int client_fd, const char* user_name, const char* cur_dir_id)
124124
send_cycle(client_fd, (char*)&data, sizeof(int));
125125
row = mysql_fetch_row(res);
126126
mysql_free_result(res);
127-
ret = sql_insert_file_trans(conn, user_name, cur_dir_id, 1, row[3], atol(row[4]), file_md5);
127+
char file_name[RESULT_LEN];
128+
strcpy(file_name, row[3]);
129+
ret = sql_insert_file_trans(conn, user_name, cur_dir_id, 1, file_name, atol(row[4]), file_md5);
128130
if (ret)
129131
{
130132
data.data_len = -1;

conf/server.conf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#max config length 50
33

44
#ip address
5-
# ip_address 192.168.5.67
6-
ip_address 172.20.10.10
5+
ip_address 192.168.5.67
76

87
#port
98
port 8888

0 commit comments

Comments
 (0)