Commit 9c8e2354 authored by Francois Cartegnie's avatar Francois Cartegnie

addons: Retrieve: narrow lock

allows UI updates while downloading
parent 71e8c79f
...@@ -498,14 +498,15 @@ static int Install( addons_storage_t *p_storage, addon_entry_t *p_entry ) ...@@ -498,14 +498,15 @@ static int Install( addons_storage_t *p_storage, addon_entry_t *p_entry )
p_entry->psz_source_module, true ); p_entry->psz_source_module, true );
if( p_module ) if( p_module )
{ {
vlc_mutex_lock( &p_entry->lock );
if ( p_finder->pf_retrieve( p_finder, p_entry ) == VLC_SUCCESS ) if ( p_finder->pf_retrieve( p_finder, p_entry ) == VLC_SUCCESS )
{ {
/* Do things while retrieved data is here */ /* Do things while retrieved data is here */
vlc_mutex_lock( &p_entry->lock );
i_ret = InstallAllFiles( p_storage, p_entry ); i_ret = InstallAllFiles( p_storage, p_entry );
vlc_mutex_unlock( &p_entry->lock );
/* !Do things while retrieved data is here */ /* !Do things while retrieved data is here */
} }
vlc_mutex_unlock( &p_entry->lock );
module_unneed( p_finder, p_module ); module_unneed( p_finder, p_module );
} }
......
...@@ -347,27 +347,39 @@ static int Find( addons_finder_t *p_finder ) ...@@ -347,27 +347,39 @@ static int Find( addons_finder_t *p_finder )
static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry ) static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry )
{ {
vlc_mutex_lock( &p_entry->lock );
if ( !p_entry->psz_archive_uri ) if ( !p_entry->psz_archive_uri )
{
vlc_mutex_unlock( &p_entry->lock );
return VLC_EGENERIC; return VLC_EGENERIC;
}
char *psz_archive_uri = strdup( p_entry->psz_archive_uri );
vlc_mutex_unlock( &p_entry->lock );
if ( !psz_archive_uri )
return VLC_ENOMEM;
/* get archive and parse manifest */ /* get archive and parse manifest */
stream_t *p_stream; stream_t *p_stream;
if ( p_entry->psz_archive_uri[0] == '/' ) if ( psz_archive_uri[0] == '/' )
{ {
/* Relative path */ /* Relative path */
char *psz_uri; char *psz_uri;
if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"%s", p_entry->psz_archive_uri ) ) if ( ! asprintf( &psz_uri, ADDONS_REPO_SCHEMEHOST"%s", psz_archive_uri ) )
{
free( psz_archive_uri );
return VLC_ENOMEM; return VLC_ENOMEM;
}
p_stream = stream_UrlNew( p_finder, psz_uri ); p_stream = stream_UrlNew( p_finder, psz_uri );
free( psz_uri ); free( psz_uri );
} }
else else
{ {
p_stream = stream_UrlNew( p_finder, p_entry->psz_archive_uri ); p_stream = stream_UrlNew( p_finder, psz_archive_uri );
} }
msg_Dbg( p_finder, "downloading archive %s", p_entry->psz_archive_uri ); msg_Dbg( p_finder, "downloading archive %s", psz_archive_uri );
free ( psz_archive_uri );
if ( !p_stream ) return VLC_EGENERIC; if ( !p_stream ) return VLC_EGENERIC;
/* In case of pf_ reuse */ /* In case of pf_ reuse */
...@@ -430,8 +442,10 @@ static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry ) ...@@ -430,8 +442,10 @@ static int Retrieve( addons_finder_t *p_finder, addon_entry_t *p_entry )
return VLC_EGENERIC; return VLC_EGENERIC;
} }
vlc_mutex_lock( &p_entry->lock );
int i_ret = ( ParseManifest( p_finder, p_entry, psz_tempfileuri, p_stream ) > 0 ) int i_ret = ( ParseManifest( p_finder, p_entry, psz_tempfileuri, p_stream ) > 0 )
? VLC_SUCCESS : VLC_EGENERIC; ? VLC_SUCCESS : VLC_EGENERIC;
vlc_mutex_unlock( &p_entry->lock );
free( psz_tempfileuri ); free( psz_tempfileuri );
stream_Delete( p_stream ); stream_Delete( p_stream );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment