fixes file upload; replaces NOW() to date() in sqlite queries
This commit is contained in:
+2
-2
@@ -234,7 +234,7 @@ int32_t db_user_auth(i_auth_t *c, o_auth_t *r) {
|
||||
|
||||
if (res == db_success) {
|
||||
char u_buf[128];
|
||||
sprintf(u_buf, "UPDATE users SET last_login = NOW() WHERE id = %u", r->uid);
|
||||
sprintf(u_buf, "UPDATE users SET last_login = date() WHERE id = %u", r->uid);
|
||||
sqlite3_exec(db, u_buf, NULL, NULL, NULL);
|
||||
return r->uid;
|
||||
}
|
||||
@@ -295,7 +295,7 @@ int32_t db_save_file(session *s) {
|
||||
|
||||
res = db_query("INSERT INTO files(user_id, name, size, created_at, "
|
||||
"hash, description, permissions) "
|
||||
"VALUES ($1, $2, $3, NOW(), $4, $5, $6) "
|
||||
"VALUES ($1, $2, $3, date(), $4, $5, $6) "
|
||||
"RETURNING id",
|
||||
db_save_file_cb, &resp_data, arg_types, s->uid, sfP->name,
|
||||
sfP->size, sfP->hash,
|
||||
|
||||
@@ -22,4 +22,5 @@ int file_receive_prepare(session *sess, char *line, server_data_t *s_d);
|
||||
int file_upload_description(session *sess, char *line, server_data_t *s_d);
|
||||
int file_save_db(session *sess, server_data_t *s_d);
|
||||
void clear_file_from_sess(session *);
|
||||
int directory_exists(const char *path);
|
||||
#endif
|
||||
+7
-2
@@ -2,6 +2,7 @@
|
||||
/* Copyright (c) 2026 Oleksandr Zhylin */
|
||||
|
||||
#include "main.h"
|
||||
#include "file_p.h"
|
||||
#include "session.h"
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
@@ -12,6 +13,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void server_main_loop(server_data_t *s_d) {
|
||||
@@ -63,8 +65,7 @@ void server_main_loop(server_data_t *s_d) {
|
||||
/* download/upload file */
|
||||
if (connections[i] != NULL && (connections[i]->state == OP_UPLOAD ||
|
||||
connections[i]->state == OP_DOWNLOAD)) {
|
||||
if (connections[i]->fd > -1 &&
|
||||
FD_ISSET(connections[i]->fd, &readfds)) {
|
||||
if (connections[i]->fd > -1 && FD_ISSET(connections[i]->fd, &readfds)) {
|
||||
perform_session_action(connections[i], NULL, s_d);
|
||||
}
|
||||
} else if (connections[i] != NULL && FD_ISSET(i, &readfds)) {
|
||||
@@ -143,4 +144,8 @@ void prepare_start(int argc, char *argv[]) {
|
||||
perror(argv[1]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (!directory_exists(STORAGE_FOLDER)) {
|
||||
mkdir(STORAGE_FOLDER, 0700);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user