void SG_server__push_add( SG_context* pCtx, SG_server * pServer, const char* pPushId, const char* psz_fragball_name, SG_vhash** ppResult ) { SG_staging* pStaging = NULL; SG_vhash* pvh_status = NULL; SG_repo* pRepo = NULL; SG_NULLARGCHECK_RETURN(pServer); SG_NULLARGCHECK_RETURN(pPushId); SG_NULLARGCHECK_RETURN(ppResult); SG_ERR_CHECK( SG_staging__open(pCtx, pPushId, &pStaging) ); SG_ERR_CHECK( SG_staging__slurp_fragball(pCtx, pStaging, psz_fragball_name) ); SG_ERR_CHECK( SG_staging__check_status(pCtx, pStaging, SG_TRUE, SG_TRUE, SG_FALSE, SG_TRUE, SG_TRUE, &pvh_status) ); *ppResult = pvh_status; pvh_status = NULL; /* fallthru */ fail: SG_REPO_NULLFREE(pCtx, pRepo); SG_VHASH_NULLFREE(pCtx, pvh_status); SG_STAGING_NULLFREE(pCtx, pStaging); }
void SG_sync_remote__push_commit( SG_context* pCtx, SG_repo* pRepo, const char* pszPushId, SG_vhash** ppResult ) { SG_staging* pStaging = NULL; SG_vhash* pvh_status = NULL; SG_NULLARGCHECK_RETURN(pszPushId); SG_NULLARGCHECK_RETURN(ppResult); SG_ERR_CHECK( SG_staging__open(pCtx, pszPushId, &pStaging) ); SG_ERR_CHECK( SG_staging__commit(pCtx, pStaging, pRepo) ); SG_ERR_CHECK( SG_staging__check_status(pCtx, pStaging, pRepo, SG_TRUE, SG_FALSE, SG_TRUE, SG_TRUE, SG_FALSE, &pvh_status) ); *ppResult = pvh_status; pvh_status = NULL; /* fallthru */ fail: SG_VHASH_NULLFREE(pCtx, pvh_status); SG_STAGING_NULLFREE(pCtx, pStaging); }
static void _free_instance_data(SG_context* pCtx, sg_pull_instance_data* pMe) { if (pMe) { SG_NULLFREE(pCtx, pMe->pszPullId); SG_STAGING_NULLFREE(pCtx, pMe->pStaging); SG_REPO_NULLFREE(pCtx, pMe->pPullIntoRepo); SG_NULLFREE(pCtx, pMe); } }
void SG_sync_remote__push_add( SG_context* pCtx, const char* pszPushId, SG_repo* pRepo, const char* psz_fragball_name, SG_vhash** ppResult ) { SG_staging* pStaging = NULL; SG_vhash* pvh_status = NULL; #if TRACE_SYNC_REMOTE SG_int64 startTime; SG_int64 endTime; double seconds; #endif SG_NULLARGCHECK_RETURN(pszPushId); SG_NULLARGCHECK_RETURN(ppResult); SG_ERR_CHECK( SG_staging__open(pCtx, pszPushId, &pStaging) ); #if TRACE_SYNC_REMOTE SG_ERR_CHECK( SG_time__get_milliseconds_since_1970_utc(pCtx, &startTime) ); #endif SG_ERR_CHECK( SG_staging__slurp_fragball(pCtx, pStaging, psz_fragball_name) ); #if TRACE_SYNC_REMOTE SG_ERR_CHECK( SG_time__get_milliseconds_since_1970_utc(pCtx, &endTime) ); seconds = ((double)endTime-(double)startTime)/1000; SG_ERR_CHECK( SG_console(pCtx, SG_CS_STDERR, "Fragball slurp took %1.3f seconds\n", seconds) ); SG_ERR_CHECK( SG_time__get_milliseconds_since_1970_utc(pCtx, &startTime) ); #endif SG_ERR_CHECK( SG_staging__check_status(pCtx, pStaging, pRepo, SG_TRUE, SG_TRUE, SG_TRUE, SG_TRUE, SG_FALSE, &pvh_status) ); #if TRACE_SYNC_REMOTE SG_ERR_CHECK( SG_time__get_milliseconds_since_1970_utc(pCtx, &endTime) ); seconds = ((double)endTime-(double)startTime)/1000; SG_ERR_CHECK( SG_console(pCtx, SG_CS_STDERR, "Status check after fragball slurp took %1.3f seconds\n", seconds) ); #endif *ppResult = pvh_status; pvh_status = NULL; /* fallthru */ fail: SG_VHASH_NULLFREE(pCtx, pvh_status); SG_STAGING_NULLFREE(pCtx, pStaging); }
void SG_server__push_get_staging_path(SG_context* pCtx, SG_server* pServer, const char* pPushId, SG_pathname** ppStagingPathname) { SG_staging* pStaging = NULL; const SG_pathname* pStagingPathname = NULL; SG_NULLARGCHECK_RETURN(pServer); SG_NULLARGCHECK_RETURN(ppStagingPathname); SG_ERR_CHECK( SG_staging__open(pCtx, pPushId, &pStaging) ); SG_ERR_CHECK( SG_staging__get_pathname(pCtx, pStaging, &pStagingPathname) ); SG_ERR_CHECK( SG_pathname__alloc__copy(pCtx, ppStagingPathname, pStagingPathname) ); /* fall through */ fail: SG_STAGING_NULLFREE(pCtx, pStaging); }
void sg_client__c__push_add(SG_context* pCtx, SG_client * pClient, SG_client_push_handle* pPush, SG_pathname** ppPath_fragball, SG_vhash** ppResult) { sg_client_c_instance_data* pMe = NULL; sg_client_c_push_handle* pMyPush = (sg_client_c_push_handle*)pPush; SG_string* pFragballName = NULL; SG_staging* pStaging = NULL; SG_vhash* pvhRepoDescriptor = NULL; SG_repo* pRepo = NULL; SG_NULLARGCHECK_RETURN(pClient); SG_NULLARGCHECK_RETURN(pPush); SG_NULLARGCHECK_RETURN(ppResult); pMe = (sg_client_c_instance_data*)pClient->p_vtable_instance_data; if (!ppPath_fragball || !*ppPath_fragball) { /* get the push's current status */ SG_ERR_CHECK( SG_staging__open(pCtx, pMyPush->pszPushId, &pStaging) ); SG_ERR_CHECK( SG_staging__check_status(pCtx, pStaging, SG_TRUE, SG_TRUE, SG_TRUE, SG_TRUE, SG_TRUE, ppResult) ); } else { /* add the fragball to the push */ // TODO: This is doing a lot more than we need here. SG_ERR_CHECK( SG_pathname__get_last(pCtx, *ppPath_fragball, &pFragballName) ); /* Tell the server to add the fragball. */ SG_ERR_CHECK( SG_server__push_add(pCtx, pMe->pServer, pMyPush->pszPushId, SG_string__sz(pFragballName), ppResult) ); SG_PATHNAME_NULLFREE(pCtx, *ppPath_fragball); } /* fall through */ fail: SG_STRING_NULLFREE(pCtx, pFragballName); SG_STAGING_NULLFREE(pCtx, pStaging); SG_REPO_NULLFREE(pCtx, pRepo); SG_VHASH_NULLFREE(pCtx, pvhRepoDescriptor); }