mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
Automatically call Inode::flush_metadata() before an Inode is destroyed.
Use a little template magic to have Retainable::release() call out to T::will_be_destroyed() if such a function exists before actually calling the destructor. This gives us full access to virtual functions in the pre-destruction code.
This commit is contained in:
@@ -129,6 +129,12 @@ Inode::~Inode()
|
||||
{
|
||||
}
|
||||
|
||||
void Inode::will_be_destroyed()
|
||||
{
|
||||
if (m_metadata_dirty)
|
||||
flush_metadata();
|
||||
}
|
||||
|
||||
int Inode::set_atime(Unix::time_t ts)
|
||||
{
|
||||
if (fs().is_readonly())
|
||||
@@ -136,7 +142,7 @@ int Inode::set_atime(Unix::time_t ts)
|
||||
if (m_metadata.atime == ts)
|
||||
return 0;
|
||||
m_metadata.atime = ts;
|
||||
m_dirty = true;
|
||||
m_metadata_dirty = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -147,7 +153,7 @@ int Inode::set_ctime(Unix::time_t ts)
|
||||
if (m_metadata.ctime == ts)
|
||||
return 0;
|
||||
m_metadata.ctime = ts;
|
||||
m_dirty = true;
|
||||
m_metadata_dirty = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -158,6 +164,6 @@ int Inode::set_mtime(Unix::time_t ts)
|
||||
if (m_metadata.mtime == ts)
|
||||
return 0;
|
||||
m_metadata.mtime = ts;
|
||||
m_dirty = true;
|
||||
m_metadata_dirty = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user