Sfoglia il codice sorgente

LibSQL+LibWebView: Do not manually serialize time stamps in CookieJar

LibSQL supports serializing time stamps as of commit
effcd080ca802515ddce8392c70df512b509f57c.

However, that commit serializes the timestamps as milliseconds, whereas
the CookieJar was serializing them as seconds. In retrospect, these
should have been updated in unison, along with the SQL heap version (as
this is a serialization change that affects the file format). So this
patch also updates the version, as this is not a backwards compatible
change.
Timothy Flynn 1 anno fa
parent
commit
5c5cbeb491

+ 1 - 1
Userland/Libraries/LibSQL/Heap.h

@@ -66,7 +66,7 @@ private:
  */
  */
 class Heap : public RefCounted<Heap> {
 class Heap : public RefCounted<Heap> {
 public:
 public:
-    static constexpr u32 VERSION = 4;
+    static constexpr u32 VERSION = 5;
 
 
     static ErrorOr<NonnullRefPtr<Heap>> create(ByteString);
     static ErrorOr<NonnullRefPtr<Heap>> create(ByteString);
     virtual ~Heap();
     virtual ~Heap();

+ 7 - 8
Userland/Libraries/LibWebView/CookieJar.cpp

@@ -484,8 +484,7 @@ static ErrorOr<Web::Cookie::Cookie> parse_cookie(ReadonlySpan<SQL::Value> row)
         if (value.type() != SQL::SQLType::Integer)
         if (value.type() != SQL::SQLType::Integer)
             return Error::from_string_view(name);
             return Error::from_string_view(name);
 
 
-        auto time = value.to_int<i64>().value();
-        field = UnixDateTime::from_seconds_since_epoch(time);
+        field = value.to_unix_date_time().value();
         return {};
         return {};
     };
     };
 
 
@@ -528,9 +527,9 @@ void CookieJar::insert_cookie_into_database(Web::Cookie::Cookie const& cookie)
                 cookie.name.to_byte_string(),
                 cookie.name.to_byte_string(),
                 cookie.value.to_byte_string(),
                 cookie.value.to_byte_string(),
                 to_underlying(cookie.same_site),
                 to_underlying(cookie.same_site),
-                cookie.creation_time.seconds_since_epoch(),
-                cookie.last_access_time.seconds_since_epoch(),
-                cookie.expiry_time.seconds_since_epoch(),
+                cookie.creation_time,
+                cookie.last_access_time,
+                cookie.expiry_time,
                 cookie.domain.to_byte_string(),
                 cookie.domain.to_byte_string(),
                 cookie.path.to_byte_string(),
                 cookie.path.to_byte_string(),
                 cookie.secure,
                 cookie.secure,
@@ -552,9 +551,9 @@ void CookieJar::update_cookie_in_database(Web::Cookie::Cookie const& cookie)
                 storage.statements.update_cookie, {}, [this]() { purge_expired_cookies(); }, {},
                 storage.statements.update_cookie, {}, [this]() { purge_expired_cookies(); }, {},
                 cookie.value.to_byte_string(),
                 cookie.value.to_byte_string(),
                 to_underlying(cookie.same_site),
                 to_underlying(cookie.same_site),
-                cookie.creation_time.seconds_since_epoch(),
-                cookie.last_access_time.seconds_since_epoch(),
-                cookie.expiry_time.seconds_since_epoch(),
+                cookie.creation_time,
+                cookie.last_access_time,
+                cookie.expiry_time,
                 cookie.secure,
                 cookie.secure,
                 cookie.http_only,
                 cookie.http_only,
                 cookie.host_only,
                 cookie.host_only,