Commit bdbf8997 authored by Vysheng's avatar Vysheng

Minor fixes

parent 52a8adbc
...@@ -1422,7 +1422,7 @@ static void create_new_binlog (struct tgl_state *TLS) { ...@@ -1422,7 +1422,7 @@ static void create_new_binlog (struct tgl_state *TLS) {
out_int (2); out_int (2);
} }
int fd = open (get_binlog_file_name (), O_WRONLY | O_EXCL | O_CREAT, 0600); int fd = open (TLS->binlog_name, O_WRONLY | O_EXCL | O_CREAT, 0600);
if (fd < 0) { if (fd < 0) {
perror ("Write new binlog"); perror ("Write new binlog");
exit (2); exit (2);
...@@ -1434,11 +1434,11 @@ static void create_new_binlog (struct tgl_state *TLS) { ...@@ -1434,11 +1434,11 @@ static void create_new_binlog (struct tgl_state *TLS) {
void tgl_replay_log (struct tgl_state *TLS) { void tgl_replay_log (struct tgl_state *TLS) {
if (!TLS->binlog_enabled) { return; } if (!TLS->binlog_enabled) { return; }
if (access (get_binlog_file_name (), F_OK) < 0) { if (access (TLS->binlog_name, F_OK) < 0) {
printf ("No binlog found. Creating new one\n"); printf ("No binlog found. Creating new one\n");
create_new_binlog (TLS); create_new_binlog (TLS);
} }
int fd = open (get_binlog_file_name (), O_RDONLY); int fd = open (TLS->binlog_name, O_RDONLY);
if (fd < 0) { if (fd < 0) {
perror ("binlog open"); perror ("binlog open");
exit (2); exit (2);
...@@ -1477,7 +1477,7 @@ void tgl_replay_log (struct tgl_state *TLS) { ...@@ -1477,7 +1477,7 @@ void tgl_replay_log (struct tgl_state *TLS) {
static int b_packet_buffer[PACKET_BUFFER_SIZE]; static int b_packet_buffer[PACKET_BUFFER_SIZE];
void tgl_reopen_binlog_for_writing (struct tgl_state *TLS) { void tgl_reopen_binlog_for_writing (struct tgl_state *TLS) {
TLS->binlog_fd = open (get_binlog_file_name (), O_WRONLY); TLS->binlog_fd = open (TLS->binlog_name, O_WRONLY);
if (TLS->binlog_fd < 0) { if (TLS->binlog_fd < 0) {
perror ("binlog open"); perror ("binlog open");
exit (2); exit (2);
......
...@@ -1050,7 +1050,6 @@ extern struct event *term_ev; ...@@ -1050,7 +1050,6 @@ extern struct event *term_ev;
void do_clear (int arg_num, struct arg args[], struct in_ev *ev) { void do_clear (int arg_num, struct arg args[], struct in_ev *ev) {
logprintf ("Do_clear\n"); logprintf ("Do_clear\n");
tgl_free_all (TLS);
free (default_username); free (default_username);
free (config_filename); free (config_filename);
free (prefix); free (prefix);
...@@ -1064,6 +1063,7 @@ void do_clear (int arg_num, struct arg args[], struct in_ev *ev) { ...@@ -1064,6 +1063,7 @@ void do_clear (int arg_num, struct arg args[], struct in_ev *ev) {
clear_history (); clear_history ();
event_free (term_ev); event_free (term_ev);
event_base_free (TLS->ev_base); event_base_free (TLS->ev_base);
tgl_free_all (TLS);
do_halt (0); do_halt (0);
} }
......
...@@ -699,6 +699,7 @@ static void accept_incoming (evutil_socket_t efd, short what, void *arg) { ...@@ -699,6 +699,7 @@ static void accept_incoming (evutil_socket_t efd, short what, void *arg) {
bufferevent_enable(bev, EV_READ|EV_WRITE); bufferevent_enable(bev, EV_READ|EV_WRITE);
} }
char *get_downloads_directory (void);
int loop (void) { int loop (void) {
//on_start (); //on_start ();
tgl_set_callback (TLS, &upd_cb); tgl_set_callback (TLS, &upd_cb);
...@@ -707,6 +708,7 @@ int loop (void) { ...@@ -707,6 +708,7 @@ int loop (void) {
tgl_set_ev_base (TLS, ev); tgl_set_ev_base (TLS, ev);
tgl_set_net_methods (TLS, &tgl_conn_methods); tgl_set_net_methods (TLS, &tgl_conn_methods);
tgl_set_timer_methods (TLS, &tgl_libevent_timers); tgl_set_timer_methods (TLS, &tgl_libevent_timers);
tgl_set_download_directory (TLS, get_downloads_directory ());
tgl_init (TLS); tgl_init (TLS);
if (binlog_enabled) { if (binlog_enabled) {
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#endif #endif
//int want_dc_num; //int want_dc_num;
char *get_downloads_directory (void); //char *get_downloads_directory (void);
//extern int offline_mode; //extern int offline_mode;
//long long cur_uploading_bytes; //long long cur_uploading_bytes;
...@@ -2492,9 +2492,9 @@ static void load_next_part (struct tgl_state *TLS, struct download *D, void *cal ...@@ -2492,9 +2492,9 @@ static void load_next_part (struct tgl_state *TLS, struct download *D, void *cal
static char buf[PATH_MAX]; static char buf[PATH_MAX];
int l; int l;
if (!D->id) { if (!D->id) {
l = tsnprintf (buf, sizeof (buf), "%s/download_%lld_%d", get_downloads_directory (), D->volume, D->local_id); l = tsnprintf (buf, sizeof (buf), "%s/download_%lld_%d.jpg", TLS->downloads_directory, D->volume, D->local_id);
} else { } else {
l = tsnprintf (buf, sizeof (buf), "%s/download_%lld", get_downloads_directory (), D->id); l = tsnprintf (buf, sizeof (buf), "%s/download_%lld", TLS->downloads_directory, D->id);
} }
if (l >= (int) sizeof (buf)) { if (l >= (int) sizeof (buf)) {
vlogprintf (E_ERROR, "Download filename is too long"); vlogprintf (E_ERROR, "Download filename is too long");
......
...@@ -30,11 +30,12 @@ ...@@ -30,11 +30,12 @@
#define TG_SERVER_3 "174.140.142.6" #define TG_SERVER_3 "174.140.142.6"
#define TG_SERVER_4 "149.154.167.91" #define TG_SERVER_4 "149.154.167.91"
#define TG_SERVER_5 "149.154.171.5" #define TG_SERVER_5 "149.154.171.5"
#define TG_SERVER_DEFAULT 4
#define TG_SERVER_TEST_1 "173.240.5.253" #define TG_SERVER_TEST_1 "173.240.5.253"
#define TG_SERVER_TEST_2 "149.154.167.40" #define TG_SERVER_TEST_2 "149.154.167.40"
#define TG_SERVER_TEST_3 "174.140.142.5" #define TG_SERVER_TEST_3 "174.140.142.5"
#define TG_SERVER_TEST_DEFAULT 2
// JUST RANDOM STRING // JUST RANDOM STRING
#define TGL_BUILD "2590" #define TGL_BUILD "2590"
...@@ -201,6 +202,8 @@ struct tgl_state { ...@@ -201,6 +202,8 @@ struct tgl_state {
void *pubKey; void *pubKey;
struct tree_query *queries_tree; struct tree_query *queries_tree;
char *base_path;
}; };
#pragma pack(pop) #pragma pack(pop)
//extern struct tgl_state tgl_state; //extern struct tgl_state tgl_state;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment