throw better IO_ERROR message on bad GITHUB URL, improved formatting and comments.
This commit is contained in:
parent
ac6347fece
commit
581d67177d
|
@ -63,7 +63,7 @@ typedef MODULE_MAP::const_iterator MODULE_CITER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class GH_CACHE
|
* Class GH_CACHE
|
||||||
* assists only within GITHUB_PLUGIN and hold a map of footprint name to wxZipEntry
|
* assists only within GITHUB_PLUGIN and holds a map of footprint name to wxZipEntry
|
||||||
*/
|
*/
|
||||||
struct GH_CACHE : public MODULE_MAP
|
struct GH_CACHE : public MODULE_MAP
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ const wxString& GITHUB_PLUGIN::GetFileExtension() const
|
||||||
wxArrayString GITHUB_PLUGIN::FootprintEnumerate(
|
wxArrayString GITHUB_PLUGIN::FootprintEnumerate(
|
||||||
const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
D(printf("%s: this:%p aLibraryPath:'%s'\n", __func__, this, TO_UTF8(aLibraryPath) );)
|
//D(printf("%s: this:%p aLibraryPath:'%s'\n", __func__, this, TO_UTF8(aLibraryPath) );)
|
||||||
|
|
||||||
cacheLib( aLibraryPath );
|
cacheLib( aLibraryPath );
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ wxArrayString GITHUB_PLUGIN::FootprintEnumerate(
|
||||||
MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
|
MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
|
||||||
const wxString& aFootprintName, const PROPERTIES* aProperties )
|
const wxString& aFootprintName, const PROPERTIES* aProperties )
|
||||||
{
|
{
|
||||||
D(printf("%s: this:%p aLibraryPath:'%s'\n", __func__, this, TO_UTF8(aLibraryPath) );)
|
// D(printf("%s: this:%p aLibraryPath:'%s'\n", __func__, this, TO_UTF8(aLibraryPath) );)
|
||||||
|
|
||||||
cacheLib( aLibraryPath );
|
cacheLib( aLibraryPath );
|
||||||
|
|
||||||
|
@ -166,18 +166,13 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR )
|
||||||
{
|
{
|
||||||
if( !m_cache || m_lib_path != aLibraryPath )
|
if( !m_cache || m_lib_path != aLibraryPath )
|
||||||
{
|
{
|
||||||
D(printf("%s: this:%p m_lib_path:'%s' aLibraryPath:'%s'\n",
|
//D(printf("%s: this:%p m_lib_path:'%s' aLibraryPath:'%s'\n", __func__, this, TO_UTF8( m_lib_path), TO_UTF8(aLibraryPath) );)
|
||||||
__func__, this, TO_UTF8( m_lib_path), TO_UTF8(aLibraryPath) );)
|
|
||||||
|
|
||||||
delete m_cache;
|
delete m_cache;
|
||||||
m_cache = new GH_CACHE();
|
m_cache = new GH_CACHE();
|
||||||
remote_get_zip( aLibraryPath );
|
remote_get_zip( aLibraryPath );
|
||||||
|
|
||||||
m_lib_path = aLibraryPath;
|
m_lib_path = aLibraryPath;
|
||||||
|
|
||||||
D(printf("%s2: this:%p m_lib_path:'%s' aLibraryPath:'%s'\n",
|
|
||||||
__func__, this, TO_UTF8( m_lib_path), TO_UTF8(aLibraryPath) );)
|
|
||||||
|
|
||||||
wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() );
|
wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() );
|
||||||
|
|
||||||
// @todo: generalize this name encoding from a PROPERTY (option) later
|
// @todo: generalize this name encoding from a PROPERTY (option) later
|
||||||
|
@ -232,7 +227,7 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR )
|
||||||
|
|
||||||
if( !repoURL_zipURL( aRepoURL, &zip_url ) )
|
if( !repoURL_zipURL( aRepoURL, &zip_url ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _("Unable to parse URL: %s"), GetChars( m_lib_path ) );
|
wxString msg = wxString::Format( _( "Unable to parse URL:\n'%s'" ), GetChars( aRepoURL ) );
|
||||||
THROW_IO_ERROR( msg );
|
THROW_IO_ERROR( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,8 +241,9 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR )
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
h.open( zip_url ); // only one file, therefore do it synchronously.
|
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
|
|
||||||
|
h.open( zip_url ); // only one file, therefore do it synchronously.
|
||||||
os << &h;
|
os << &h;
|
||||||
|
|
||||||
// Keep zip file byte image in RAM. That plus the MODULE_MAP will constitute
|
// Keep zip file byte image in RAM. That plus the MODULE_MAP will constitute
|
||||||
|
@ -295,4 +291,3 @@ int main( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue