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

LibSQL supports serializing time stamps as of commit
effcd080ca.

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.
This commit is contained in:
Timothy Flynn 2024-01-10 07:05:15 -05:00 committed by Andreas Kling
parent 7a912ca891
commit 5c5cbeb491
Notes: sideshowbarker 2024-07-16 23:17:55 +09:00
2 changed files with 8 additions and 9 deletions

View file

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

View file

@ -484,8 +484,7 @@ static ErrorOr<Web::Cookie::Cookie> parse_cookie(ReadonlySpan<SQL::Value> row)
if (value.type() != SQL::SQLType::Integer)
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 {};
};
@ -528,9 +527,9 @@ void CookieJar::insert_cookie_into_database(Web::Cookie::Cookie const& cookie)
cookie.name.to_byte_string(),
cookie.value.to_byte_string(),
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.path.to_byte_string(),
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(); }, {},
cookie.value.to_byte_string(),
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.http_only,
cookie.host_only,