Mercurial
comparison mrjunejune/main.c @ 168:f3084bca7317
[Misc] Fixed all errors and all tests should pass now.
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 19 Jan 2026 16:29:02 -0800 |
| parents | 1c0878eb17de |
| children | 295ac2e5ec00 |
comparison
equal
deleted
inserted
replaced
| 167:589bab390fb4 | 168:f3084bca7317 |
|---|---|
| 185 const char *content_length_str = ((Seobeo_Request_Entry*)cl_kv)->value; | 185 const char *content_length_str = ((Seobeo_Request_Entry*)cl_kv)->value; |
| 186 size_t file_size = atoi(content_length_str); | 186 size_t file_size = atoi(content_length_str); |
| 187 | 187 |
| 188 printf("DEBUG: Converting image, file_size=%zu bytes\n", file_size); | 188 printf("DEBUG: Converting image, file_size=%zu bytes\n", file_size); |
| 189 | 189 |
| 190 | |
| 191 int open_flags = O_RDWR | O_CREAT | O_EXCL; | 190 int open_flags = O_RDWR | O_CREAT | O_EXCL; |
| 192 | 191 |
| 193 char *uuid4 = (char *)Dowa_Arena_Allocate(arena, UUID_LEN); | 192 char *uuid4 = (char *)Dowa_Arena_Allocate(arena, UUID_LEN); |
| 194 uint32 seed = (uint32)time(NULL) ^ (uint32)pthread_self() ^ counter++; | 193 uint32 seed = (uint32)time(NULL) ^ (uint32)pthread_self() ^ counter++; |
| 195 Dowa_String_UUID(seed, uuid4); | 194 Dowa_String_UUID(seed, uuid4); |
| 304 const char *content_length_str = ((Seobeo_Request_Entry*)cl_kv)->value; | 303 const char *content_length_str = ((Seobeo_Request_Entry*)cl_kv)->value; |
| 305 size_t file_size = atoi(content_length_str); | 304 size_t file_size = atoi(content_length_str); |
| 306 | 305 |
| 307 printf("DEBUG: Converting video, file_size=%zu bytes\n", file_size); | 306 printf("DEBUG: Converting video, file_size=%zu bytes\n", file_size); |
| 308 | 307 |
| 308 int open_flags = O_RDWR | O_CREAT | O_EXCL; | |
| 309 | |
| 309 char *uuid4 = (char *)Dowa_Arena_Allocate(arena, UUID_LEN); | 310 char *uuid4 = (char *)Dowa_Arena_Allocate(arena, UUID_LEN); |
| 310 Dowa_String_UUID((uint32)time(NULL), uuid4); | 311 uint32 seed = (uint32)time(NULL) ^ (uint32)pthread_self() ^ counter++; |
| 312 Dowa_String_UUID(seed, uuid4); | |
| 311 char *input_path = Dowa_Arena_Allocate(arena, TMP_FILE_LENGTH); | 313 char *input_path = Dowa_Arena_Allocate(arena, TMP_FILE_LENGTH); |
| 312 snprintf(input_path, TMP_FILE_LENGTH, "/tmp/%s", uuid4); | 314 snprintf(input_path, TMP_FILE_LENGTH, "/tmp/%s", uuid4); |
| 313 int input_fd = mkstemp(input_path); | 315 Seobeo_Log(SEOBEO_DEBUG, "Input path: %s\n", input_path); |
| 316 | |
| 317 int input_fd = open(input_path, open_flags, 0600); | |
| 314 if (input_fd == -1) | 318 if (input_fd == -1) |
| 315 { | 319 { |
| 320 Seobeo_Log(SEOBEO_DEBUG, "errno: %d (%s)\n", errno, strerror(errno)); | |
| 316 char *error_msg = "Failed to create temporary file"; | 321 char *error_msg = "Failed to create temporary file"; |
| 317 Dowa_HashMap_Push_Arena(resp, "status", "500", arena); | 322 Dowa_HashMap_Push_Arena(resp, "status", "500", arena); |
| 318 Dowa_HashMap_Push_Arena(resp, "content-type", "text/plain", arena); | 323 Dowa_HashMap_Push_Arena(resp, "content-type", "text/plain", arena); |
| 319 Dowa_HashMap_Push_Arena(resp, "body", error_msg, arena); | 324 Dowa_HashMap_Push_Arena(resp, "body", error_msg, arena); |
| 320 return resp; | 325 return resp; |
| 321 } | 326 } |
| 322 | 327 |
| 323 write(input_fd, file_data, file_size); | 328 write(input_fd, file_data, file_size); |
| 324 close(input_fd); | 329 close(input_fd); |
| 325 | 330 |
| 326 int open_flags = O_RDWR | O_CREAT | O_EXCL; | 331 seed = (uint32)time(NULL) ^ (uint32)pthread_self() ^ counter++; |
| 327 | |
| 328 uint32 seed = (uint32)time(NULL) ^ (uint32)pthread_self() ^ counter++;; | |
| 329 Dowa_String_UUID(seed, uuid4); | 332 Dowa_String_UUID(seed, uuid4); |
| 330 char *output_path = (char *)Dowa_Arena_Allocate(arena, TMP_FILE_LENGTH);; | 333 char *output_path = (char *)Dowa_Arena_Allocate(arena, TMP_FILE_LENGTH);; |
| 331 snprintf(output_path, TMP_FILE_LENGTH, "/tmp/%s.mp4", uuid4); | 334 snprintf(output_path, TMP_FILE_LENGTH, "/tmp/%s.mp4", uuid4); |
| 332 int output_fd = open(output_path, open_flags, 0600); | 335 int output_fd = open(output_path, open_flags, 0600); |
| 333 if (output_fd == -1) | 336 if (output_fd == -1) |