svtools/source/misc/templatefoldercache.cxx |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 34ad8590e973f1ea6e50c87313939eb489551770
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Wed Apr 23 14:20:23 2025 +0200
Commit:     Thorsten Behrens <thorsten.behr...@allotropia.de>
CommitDate: Thu Apr 24 16:57:39 2025 +0200

    Compare normalized nanosec timestamps in 
TemplateFolderCacheImpl::equalStates
    
    After 9830fd36dbdb72c79703b0c61efc027fba793c5a "date/time IDL datatypes
    incompatible change", 4fa553e4071a0ba4981a690429903c4e68607864 "fdo#62088: 
Fix
    regression introduced by the DateTime incompatible change." had fixed
    writing/reading timestamps to/from the .templdir.cache file, by cutting from
    nanosecond precision back to 1/100th-second precision.  But in the call to
    TemplateFolderCacheImpl::equalState, the (cut-down) timestamps read from the
    .templdir.cache file were then compared against (not--cut-down) timestamps
    reported by the filesystem, potentially causing equalState to erroneously 
return
    false.  (This is only relevant on Windows, as the non-Windows 
implementation in
    sal/osl/unx/file_stat.cxx always sets Nanonsec = 0 for all the timestamps it
    reports.)
    
    Change-Id: I34b99024531d4d2e49bb53450e8f6fd13397f237
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184505
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <stephan.bergm...@allotropia.de>
    (cherry picked from commit f5cca58c2ea765b08cbcc771deb4fa75ead1870e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184541
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>

diff --git a/svtools/source/misc/templatefoldercache.cxx 
b/svtools/source/misc/templatefoldercache.cxx
index 14f801f2a2fd..9773e43b5bc8 100644
--- a/svtools/source/misc/templatefoldercache.cxx
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -134,6 +134,12 @@ namespace svt
         // attribute access
         OUString                 getURL( ) const                             { 
return m_aURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ); }
         void                     setModDate( const util::DateTime& _rDate )  { 
m_aLastModified = _rDate; }
+        void                     setModDateNormalized( const util::DateTime& 
_rDate ) {
+            auto norm = _rDate;
+            norm.NanoSeconds
+                = (norm.NanoSeconds / tools::Time::nanoPerCenti) * 
tools::Time::nanoPerCenti;
+            setModDate(norm);
+        }
         const util::DateTime&    getModDate( ) const                         { 
return m_aLastModified; }
 
         TemplateFolderContent&   getSubContents()            { return 
m_aSubContents; }
@@ -568,9 +574,10 @@ namespace svt
                     ::rtl::Reference< TemplateContent > xChild = new 
TemplateContent( std::move(aSubContentURL) );
 
                     // the modified date
-                    xChild->setModDate( xRow->getTimestamp( 2 ) );  // date 
modified
+                    xChild->setModDateNormalized( xRow->getTimestamp( 2 ) );  
// date modified
                     if ( xRow->wasNull() )
-                        xChild->setModDate( xRow->getTimestamp( 3 ) );  // 
fallback: date created
+                        xChild->setModDateNormalized( xRow->getTimestamp( 3 ) 
);
+                            // fallback: date created
 
                     // push back this content
                     _rxRoot->push_back( xChild );

Reply via email to