mirror of https://github.com/vitalif/grive2
use ctime instead of mtime to detect changes
parent
b6fb4a604e
commit
88cdb576c4
|
@ -61,7 +61,7 @@ void Entry::FromLocal( const fs::path& path )
|
|||
m_filename = path.filename().string() ;
|
||||
m_kind = fs::is_directory(path) ? "folder" : "file" ;
|
||||
m_md5 = fs::is_directory(path) ? "" : crypt::MD5( path ) ;
|
||||
m_mtime = fs::exists(path) ? os::FileMTime( path ) : DateTime() ;
|
||||
m_mtime = fs::exists(path) ? os::FileCTime( path ) : DateTime() ;
|
||||
}
|
||||
|
||||
void Entry::Update( const xml::Node& n )
|
||||
|
|
|
@ -179,7 +179,7 @@ void Resource::FromLocal( const DateTime& last_sync )
|
|||
// if the file is not created after last sync, assume file is
|
||||
// remote_deleted first, it will be updated to sync/remote_changed
|
||||
// in FromRemote()
|
||||
DateTime mtime = os::FileMTime( path ) ;
|
||||
DateTime mtime = os::FileCTime( path ) ;
|
||||
m_state = ( mtime > last_sync ? local_new : remote_deleted ) ;
|
||||
|
||||
m_entry.FromLocal( path ) ;
|
||||
|
|
|
@ -39,12 +39,12 @@
|
|||
|
||||
namespace gr { namespace os {
|
||||
|
||||
DateTime FileMTime( const fs::path& filename )
|
||||
DateTime FileCTime( const fs::path& filename )
|
||||
{
|
||||
return FileMTime( filename.string() ) ;
|
||||
return FileCTime( filename.string() ) ;
|
||||
}
|
||||
|
||||
DateTime FileMTime( const std::string& filename )
|
||||
DateTime FileCTime( const std::string& filename )
|
||||
{
|
||||
struct stat s = {} ;
|
||||
if ( ::stat( filename.c_str(), &s ) != 0 )
|
||||
|
@ -58,9 +58,9 @@ DateTime FileMTime( const std::string& filename )
|
|||
}
|
||||
|
||||
#if defined __APPLE__ && defined __DARWIN_64_BIT_INO_T
|
||||
return DateTime( s.st_mtimespec.tv_sec, s.st_mtimespec.tv_nsec ) ;
|
||||
return DateTime( s.st_ctimespec.tv_sec, s.st_ctimespec.tv_nsec ) ;
|
||||
#else
|
||||
return DateTime( s.st_mtim.tv_sec, s.st_mtim.tv_nsec);
|
||||
return DateTime( s.st_ctim.tv_sec, s.st_ctim.tv_nsec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace os
|
|||
{
|
||||
struct Error : virtual Exception {} ;
|
||||
|
||||
DateTime FileMTime( const std::string& filename ) ;
|
||||
DateTime FileMTime( const fs::path& filename ) ;
|
||||
DateTime FileCTime( const std::string& filename ) ;
|
||||
DateTime FileCTime( const fs::path& filename ) ;
|
||||
|
||||
void SetFileTime( const std::string& filename, const DateTime& t ) ;
|
||||
void SetFileTime( const fs::path& filename, const DateTime& t ) ;
|
||||
|
|
Loading…
Reference in New Issue