From 81a55e77afa4e8f7c28c04a6a8f6ac69eca9f1f9 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 23 Sep 2022 20:02:45 +0200 Subject: [PATCH] Preserve timestamps when extracting the squashfs Backport of https://github.com/AppImage/AppImageKit/pull/1216 --- src/runtime/runtime.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 0f4cb9c..20eb972 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -764,6 +764,11 @@ bool extract_appimage(const char* const appimage_path, const char* const _prefix fwrite(buf, 1, bytes_at_a_time, f); bytes_already_read = bytes_already_read + bytes_at_a_time; } + fflush(f); + int fd = fileno(f); + struct timespec times[] = { st.st_atim, st.st_mtim }; + if (futimens(fd, times) != 0) + fprintf(stderr, "futimens: %s\n", strerror(errno)); fclose(f); chmod(prefixed_path_to_extract, st.st_mode); if (!rv)