]> git.ipfire.org Git - pakfire.git/commitdiff
file: Split time into ctime and mtime
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Mar 2021 22:32:35 +0000 (22:32 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 8 Mar 2021 22:32:35 +0000 (22:32 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/db.c
src/libpakfire/file.c
src/libpakfire/filelist.c
src/libpakfire/include/pakfire/file.h
src/libpakfire/packager.c

index 21d886b7a7390d4f023e0c39d89c0383ea7937c7..a163c4c8f57b6660e697fa4a31e9d7f15dc1ddbb 100644 (file)
@@ -302,6 +302,7 @@ static int pakfire_db_create_schema(struct pakfire_db* db) {
                        "user           TEXT, "
                        "'group'        TEXT, "
                        "hash1          TEXT, "
+                       "ctime          INTEGER, "
                        "mtime          INTEGER, "
                        "capabilities   TEXT, "
                        "FOREIGN KEY (pkg) REFERENCES packages(id) ON DELETE CASCADE"
@@ -775,7 +776,7 @@ static int pakfire_db_add_files(struct pakfire_db* db, unsigned long id, Pakfire
        }
 
        const char* sql = "INSERT INTO files(pkg, path, size, type, config, datafile, mode, "
-               "user, 'group', hash1, mtime, capabilities) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+               "user, 'group', hash1, ctime, mtime, capabilities) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
 
        // Prepare the statement
        r = sqlite3_prepare_v2(db->handle, sql, -1, &stmt, NULL);
@@ -882,10 +883,20 @@ static int pakfire_db_add_files(struct pakfire_db* db, unsigned long id, Pakfire
                        goto END;
                }
 
+               // Bind ctime
+               time_t ctime = pakfire_file_get_ctime(file);
+
+               r = sqlite3_bind_int64(stmt, 11, ctime);
+               if (r) {
+                       ERROR(db->pakfire, "Could not bind ctime: %s\n", sqlite3_errmsg(db->handle));
+                       pakfire_file_unref(file);
+                       goto END;
+               }
+
                // Bind mtime
-               time_t mtime = pakfire_file_get_time(file);
+               time_t mtime = pakfire_file_get_mtime(file);
 
-               r = sqlite3_bind_int64(stmt, 11, mtime);
+               r = sqlite3_bind_int64(stmt, 12, mtime);
                if (r) {
                        ERROR(db->pakfire, "Could not bind mtime: %s\n", sqlite3_errmsg(db->handle));
                        pakfire_file_unref(file);
@@ -893,7 +904,7 @@ static int pakfire_db_add_files(struct pakfire_db* db, unsigned long id, Pakfire
                }
 
                // Bind capabilities - XXX TODO
-               r = sqlite3_bind_null(stmt, 12);
+               r = sqlite3_bind_null(stmt, 13);
                if (r) {
                        ERROR(db->pakfire, "Could not bind capabilities: %s\n", sqlite3_errmsg(db->handle));
                        pakfire_file_unref(file);
index c7b92fe685269fc5599f8a5d3d62373965aece3f..6326ccfebf27b2aaa84db13d4f534e751f69402d 100644 (file)
@@ -50,7 +50,9 @@ struct _PakfireFile {
        char group[256];
 
        mode_t mode;
-       time_t time;
+
+       time_t ctime;
+       time_t mtime;
 
        char* chksum;
 
@@ -87,8 +89,9 @@ PAKFIRE_EXPORT int pakfire_file_copy_stat(PakfireFile file, struct stat* stat) {
        pakfire_file_set_user(file, "root");
        pakfire_file_set_group(file, "root");
 
-       // Set time
-       pakfire_file_set_time(file, stat->st_ctime);
+       // Set times
+       pakfire_file_set_ctime(file, stat->st_ctime);
+       pakfire_file_set_mtime(file, stat->st_mtime);
 
        return 0;
 }
@@ -109,8 +112,9 @@ int pakfire_file_copy_archive_entry(PakfireFile file, struct archive_entry* entr
        // Set group
        pakfire_file_set_group(file, archive_entry_gname(entry));
 
-       // Set mtime
-       pakfire_file_set_time(file, archive_entry_mtime(entry));
+       // Set times
+       pakfire_file_set_ctime(file, archive_entry_ctime(entry));
+       pakfire_file_set_mtime(file, archive_entry_mtime(entry));
 
        return 0;
 }
@@ -200,12 +204,20 @@ PAKFIRE_EXPORT void pakfire_file_set_mode(PakfireFile file, mode_t mode) {
        file->mode = mode;
 }
 
-PAKFIRE_EXPORT time_t pakfire_file_get_time(PakfireFile file) {
-       return file->time;
+PAKFIRE_EXPORT time_t pakfire_file_get_ctime(PakfireFile file) {
+       return file->ctime;
+}
+
+PAKFIRE_EXPORT void pakfire_file_set_ctime(PakfireFile file, time_t time) {
+       file->ctime = time;
+}
+
+PAKFIRE_EXPORT time_t pakfire_file_get_mtime(PakfireFile file) {
+       return file->mtime;
 }
 
-PAKFIRE_EXPORT void pakfire_file_set_time(PakfireFile file, time_t time) {
-       file->time = time;
+PAKFIRE_EXPORT void pakfire_file_set_mtime(PakfireFile file, time_t time) {
+       file->mtime = time;
 }
 
 PAKFIRE_EXPORT const char* pakfire_file_get_chksum(PakfireFile file) {
index 05ded01235bdd84f0bd4a9e858164eac61f721c7..dc3a9bfecbde3456bbb917bdca9c3448e4732cbc 100644 (file)
@@ -190,7 +190,7 @@ static int pakfire_filelist_parse_line(PakfireFile* file, Pakfire pakfire,
                                // time
                                case 5:
                                        time = atoi(word);
-                                       pakfire_file_set_time(*file, time);
+                                       pakfire_file_set_ctime(*file, time);
                                        break;
 
                                // checksum
@@ -241,7 +241,7 @@ static int pakfire_filelist_parse_line(PakfireFile* file, Pakfire pakfire,
                                // time
                                case 6:
                                        time = atoi(word);
-                                       pakfire_file_set_time(*file, time);
+                                       pakfire_file_set_ctime(*file, time);
                                        break;
 
                                // checksum
index b608ef8442cef774fa12347d88b5f601479ddf06..79b4112e4afc9e89b98b04c3483b40fc60d66679 100644 (file)
@@ -54,8 +54,10 @@ void pakfire_file_set_group(PakfireFile file, const char* group);
 mode_t pakfire_file_get_mode(PakfireFile file);
 void pakfire_file_set_mode(PakfireFile file, mode_t mode);
 
-time_t pakfire_file_get_time(PakfireFile file);
-void pakfire_file_set_time(PakfireFile file, time_t time);
+time_t pakfire_file_get_ctime(PakfireFile file);
+void pakfire_file_set_ctime(PakfireFile file, time_t time);
+time_t pakfire_file_get_mtime(PakfireFile file);
+void pakfire_file_set_mtime(PakfireFile file, time_t time);
 
 const char* pakfire_file_get_chksum(PakfireFile file);
 void pakfire_file_set_chksum(PakfireFile file, const char* chksum);
index 248d2ec7ad68bd11e49a9fdcdb19df9c872ea0e2..7ddd4fa0d382c71575670e37eed99ddd8582819c 100644 (file)
@@ -263,7 +263,7 @@ static int pakfire_packager_write_filelist(struct pakfire_packager* packager,
                        pakfire_file_get_user(file),
                        pakfire_file_get_group(file),
                        pakfire_file_get_mode(file),
-                       pakfire_file_get_time(file),
+                       pakfire_file_get_ctime(file),
                        (chksum) ? chksum : "-",
                        "-", // XXX capabilities
                        pakfire_file_get_path(file)