diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index e89b85dd8f..bda040ef47 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -241,7 +241,7 @@ long long FP_LIB_TABLE::GenerateTimestamp( const wxString* aNickname ) { const FP_LIB_TABLE_ROW* row = FindRow( *aNickname ); wxASSERT( (PLUGIN*) row->plugin ); - return row->plugin->GetLibraryTimestamp(); + return row->plugin->GetLibraryTimestamp( row->GetFullURI( true ) ); } long long hash = 0; @@ -250,7 +250,7 @@ long long FP_LIB_TABLE::GenerateTimestamp( const wxString* aNickname ) { const FP_LIB_TABLE_ROW* row = FindRow( nickname ); wxASSERT( (PLUGIN*) row->plugin ); - hash += row->plugin->GetLibraryTimestamp(); + hash += row->plugin->GetLibraryTimestamp( row->GetFullURI( true ) ); } return hash; diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h index d38ef63c1e..c41807f18b 100644 --- a/pcbnew/eagle_plugin.h +++ b/pcbnew/eagle_plugin.h @@ -98,9 +98,9 @@ public: MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL ) override; - long long GetLibraryTimestamp() const override + long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override { - return getModificationTime( m_lib_path ).GetValue().GetValue(); + return getModificationTime( aLibraryPath ).GetValue().GetValue(); } bool IsFootprintLibWritable( const wxString& aLibraryPath ) override diff --git a/pcbnew/footprint_info_impl.cpp b/pcbnew/footprint_info_impl.cpp index c2dff3b0b2..0ff69afb5d 100644 --- a/pcbnew/footprint_info_impl.cpp +++ b/pcbnew/footprint_info_impl.cpp @@ -118,7 +118,8 @@ void FOOTPRINT_LIST_IMPL::loader_job() bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname, WX_PROGRESS_REPORTER* aProgressReporter ) { - if( aTable->GenerateTimestamp( aNickname ) == m_list_timestamp ) + long long libraryTimestamp = aTable->GenerateTimestamp( aNickname ); + if( m_list_timestamp == libraryTimestamp ) return true; m_progress_reporter = aProgressReporter; @@ -166,7 +167,7 @@ bool FOOTPRINT_LIST_IMPL::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxStri ( _( "Loading incomplete; cancelled by user." ), nullptr, nullptr, 0 ) ); } - m_list_timestamp = aTable->GenerateTimestamp( aNickname ); + m_list_timestamp = libraryTimestamp; m_progress_reporter = nullptr; return m_errors.empty(); diff --git a/pcbnew/github/github_plugin.cpp b/pcbnew/github/github_plugin.cpp index f3e7b5a517..1ddaab5ee8 100644 --- a/pcbnew/github/github_plugin.cpp +++ b/pcbnew/github/github_plugin.cpp @@ -464,6 +464,29 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP } +long long GITHUB_PLUGIN::GetLibraryTimestamp( const wxString& aLibraryPath ) const +{ + // This plugin currently relies on the nginx server for caching (see comments + // at top of file). + // Since only the nginx server holds the timestamp information, we must defeat + // all caching above the nginx server. + return wxDateTime::Now().GetValue().GetValue(); + +#if 0 + // If we have no cache, return a number which won't match any stored timestamps + if( !m_gh_cache || m_lib_path != aLibraryPath ) + return wxDateTime::Now().GetValue().GetValue(); + + long long hash = m_gh_cache->GetTimestamp(); + + if( m_pretty_dir.size() ) + hash += PCB_IO::GetLibraryTimestamp( m_pretty_dir ); + + return hash; +#endif +} + + bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, std::string* aZipURL ) { // e.g. "https://github.com/liftoff-sr/pretty_footprints" diff --git a/pcbnew/github/github_plugin.h b/pcbnew/github/github_plugin.h index 76b0e2ef9c..ca633b1a1f 100644 --- a/pcbnew/github/github_plugin.h +++ b/pcbnew/github/github_plugin.h @@ -184,6 +184,8 @@ public: bool IsFootprintLibWritable( const wxString& aLibraryPath ) override; + long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override; + void FootprintLibOptions( PROPERTIES* aListToAppendTo ) const override; // Since I derive from PCB_IO, I have to implement this, else I'd inherit his, which is bad since diff --git a/pcbnew/gpcb_plugin.cpp b/pcbnew/gpcb_plugin.cpp index a560546e9c..94abf92915 100644 --- a/pcbnew/gpcb_plugin.cpp +++ b/pcbnew/gpcb_plugin.cpp @@ -1120,10 +1120,10 @@ bool GPCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPER } -long long GPCB_PLUGIN::GetLibraryTimestamp() const +long long GPCB_PLUGIN::GetLibraryTimestamp( const wxString& aLibraryPath ) const { // If we have no cache, return a number which won't match any stored timestamps - if( !m_cache ) + if( !m_cache || !m_cache->IsPath( aLibraryPath ) ) return wxDateTime::Now().GetValue().GetValue(); return m_cache->GetTimestamp(); diff --git a/pcbnew/gpcb_plugin.h b/pcbnew/gpcb_plugin.h index a951084481..8ae6dc5e8b 100644 --- a/pcbnew/gpcb_plugin.h +++ b/pcbnew/gpcb_plugin.h @@ -77,7 +77,7 @@ public: bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL ) override; - long long GetLibraryTimestamp() const override; + long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override; bool IsFootprintLibWritable( const wxString& aLibraryPath ) override; diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 3f5efb4b0e..c6e3905ab7 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -358,7 +358,7 @@ public: * directory). * Timestamps should not be considered ordered; they either match or they don't. */ - virtual long long GetLibraryTimestamp() const = 0; + virtual long long GetLibraryTimestamp( const wxString& aLibraryPath ) const = 0; /** * Function PrefetchLib diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 891a22f325..eef47d7a51 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1947,7 +1947,7 @@ void PCB_IO::init( const PROPERTIES* aProperties ) void PCB_IO::validateCache( const wxString& aLibraryPath, bool checkModified ) { - if( !m_cache || ( checkModified && m_cache->IsModified() ) ) + if( !m_cache || !m_cache->IsPath( aLibraryPath ) || ( checkModified && m_cache->IsModified() ) ) { // a spectacular episode in memory management: delete m_cache; @@ -2130,10 +2130,10 @@ void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo -long long PCB_IO::GetLibraryTimestamp() const +long long PCB_IO::GetLibraryTimestamp( const wxString& aLibraryPath ) const { // If we have no cache, return a number which won't match any stored timestamps - if( !m_cache ) + if( !m_cache || !m_cache->IsPath( aLibraryPath ) ) return wxDateTime::Now().GetValue().GetValue(); return m_cache->GetTimestamp(); diff --git a/pcbnew/kicad_plugin.h b/pcbnew/kicad_plugin.h index 497d4c392c..762358d13c 100644 --- a/pcbnew/kicad_plugin.h +++ b/pcbnew/kicad_plugin.h @@ -133,7 +133,7 @@ public: void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName, const PROPERTIES* aProperties = NULL ) override; - long long GetLibraryTimestamp() const override; + long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override; void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL) override; diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 7e20aa936d..2876f6bfc7 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -3383,10 +3383,10 @@ void LP_CACHE::LoadModules( LINE_READER* aReader ) } -long long LEGACY_PLUGIN::GetLibraryTimestamp() const +long long LEGACY_PLUGIN::GetLibraryTimestamp( const wxString& aLibraryPath ) const { // If we have no cache, return a number which won't match any stored timestamps - if( !m_cache ) + if( !m_cache || m_cache->m_lib_path != aLibraryPath ) return wxDateTime::Now().GetValue().GetValue(); return m_cache->GetLibModificationTime().GetValue().GetValue(); diff --git a/pcbnew/legacy_plugin.h b/pcbnew/legacy_plugin.h index f8390b18a3..e4ab1bea20 100644 --- a/pcbnew/legacy_plugin.h +++ b/pcbnew/legacy_plugin.h @@ -93,7 +93,7 @@ public: bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL ) override; - long long GetLibraryTimestamp() const override; + long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override; bool IsFootprintLibWritable( const wxString& aLibraryPath ) override; diff --git a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h index 138463825d..45e95fffae 100644 --- a/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h +++ b/pcbnew/pcad2kicadpcb_plugin/pcad_plugin.h @@ -47,7 +47,7 @@ public: const wxString GetFileExtension() const override; - long long GetLibraryTimestamp() const override + long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override { // No support for libraries.... return 0;