Mercurial
diff 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 |
line wrap: on
line diff
--- a/mrjunejune/main.c Mon Jan 19 16:28:45 2026 -0800 +++ b/mrjunejune/main.c Mon Jan 19 16:29:02 2026 -0800 @@ -187,7 +187,6 @@ printf("DEBUG: Converting image, file_size=%zu bytes\n", file_size); - int open_flags = O_RDWR | O_CREAT | O_EXCL; char *uuid4 = (char *)Dowa_Arena_Allocate(arena, UUID_LEN); @@ -306,13 +305,19 @@ printf("DEBUG: Converting video, file_size=%zu bytes\n", file_size); + int open_flags = O_RDWR | O_CREAT | O_EXCL; + char *uuid4 = (char *)Dowa_Arena_Allocate(arena, UUID_LEN); - Dowa_String_UUID((uint32)time(NULL), uuid4); + uint32 seed = (uint32)time(NULL) ^ (uint32)pthread_self() ^ counter++; + Dowa_String_UUID(seed, uuid4); char *input_path = Dowa_Arena_Allocate(arena, TMP_FILE_LENGTH); snprintf(input_path, TMP_FILE_LENGTH, "/tmp/%s", uuid4); - int input_fd = mkstemp(input_path); + Seobeo_Log(SEOBEO_DEBUG, "Input path: %s\n", input_path); + + int input_fd = open(input_path, open_flags, 0600); if (input_fd == -1) { + Seobeo_Log(SEOBEO_DEBUG, "errno: %d (%s)\n", errno, strerror(errno)); char *error_msg = "Failed to create temporary file"; Dowa_HashMap_Push_Arena(resp, "status", "500", arena); Dowa_HashMap_Push_Arena(resp, "content-type", "text/plain", arena); @@ -323,9 +328,7 @@ write(input_fd, file_data, file_size); close(input_fd); - int open_flags = O_RDWR | O_CREAT | O_EXCL; - - uint32 seed = (uint32)time(NULL) ^ (uint32)pthread_self() ^ counter++;; + seed = (uint32)time(NULL) ^ (uint32)pthread_self() ^ counter++; Dowa_String_UUID(seed, uuid4); char *output_path = (char *)Dowa_Arena_Allocate(arena, TMP_FILE_LENGTH);; snprintf(output_path, TMP_FILE_LENGTH, "/tmp/%s.mp4", uuid4);