Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vdb 5238 #160

Open
wants to merge 4 commits into
base: engineering
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions interfaces/kfg/kfg-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ KConfigParse ( KConfig * self, const char* path, const char * src );


bool KRepositoryFromNgc(const struct KRepository * self);
const char * KConfigGetNgcFile(void);

#ifdef __cplusplus
}
Expand Down
73 changes: 73 additions & 0 deletions interfaces/vfs/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,79 @@ VFS_EXTERN rc_t CC VFSManagerLogNamesServiceErrors(struct VFSManager* self,
VFS_EXTERN rc_t CC VFSManagerGetLogNamesServiceErrors(VFSManager * self,
bool * enabled);

/*****************************************************************************/
/* Resolving of accessions/files/path-s */
/*****************************************************************************/

/* Resolve, ResolveVPath
* Use these functions if you just need to resolve input to VPath
*
* Input is resolved to local path (if found locally),
* otherwise remote.
* If you need to know if a path is local or remote - use VPathIsRemote(out).
* N.B. there is no attempt of remote resolution if input is found locally.
*/
VFS_EXTERN rc_t CC VFSManagerResolve(const VFSManager * self,
const char * in, const struct VPath ** out);
VFS_EXTERN rc_t CC VFSManagerResolveVPath(const VFSManager * self,
const struct VPath * in, const struct VPath ** out);

/* ResolveWithCache, ResolveVPathWithCache
* Use these functions:
* if local location if enough (if found),
* otherwise you need to have remote and cache locations.
*
* If input if found locally - local path is returned,
* otherwise remote and cache location are returned.
* Returned cache location will be NULL if input is found locally.
* Returned cache location can be NULL if caching is disabled.
* If you need to know if a path is local or remote - use VPathIsRemote(out).
* N.B. there is no attempt of remote resolution if input is found locally.
*/
VFS_EXTERN rc_t CC VFSManagerResolveWithCache(const VFSManager * self,
const char * in, const struct VPath ** out, const struct VPath ** cache);
VFS_EXTERN rc_t CC VFSManagerResolveVPathWithCache(const VFSManager * self,
const struct VPath * in,
const struct VPath ** out, const struct VPath ** cache);

/* ResolveLocal, ResolveVPathLocal
* Use these functions:
* if you require input to be found locally.
*/
VFS_EXTERN rc_t CC VFSManagerResolveLocal(const VFSManager * self,
const char * in, const struct VPath ** out);
VFS_EXTERN rc_t CC VFSManagerResolveVPathLocal(const VFSManager * self,
const struct VPath * in, const struct VPath ** out);

/* ResolveRemote, ResolveVPathRemote
* Use these functions:
* if you require input to be found remotely
* e.g., for prefetching.
*
* cache output parameted can be NULL
*/
VFS_EXTERN rc_t CC VFSManagerResolveRemote(const VFSManager * self,
const char * in,
const struct VPath ** remote, const struct VPath ** cache);
VFS_EXTERN rc_t CC VFSManagerResolveVPathRemote(const VFSManager * self,
const struct VPath * in,
const struct VPath ** remote, const struct VPath ** cache);

/* ResolveAll, ResolveVPathAll
* Use these functions:
* if you require to have local and remote resolution
* e.g., for reporting.
*
* cache output parameted can be NULL
*/
VFS_EXTERN rc_t CC VFSManagerResolveAll(const VFSManager * self,
const char * in, const struct VPath ** local,
const struct VPath ** remote, const struct VPath ** cache);
VFS_EXTERN rc_t CC VFSManagerResolveVPathAll(const VFSManager * self,
const struct VPath * in, const struct VPath ** local,
const struct VPath ** remote, const struct VPath ** cache);

/*****************************************************************************/

#ifdef __cplusplus
}
Expand Down
5 changes: 5 additions & 0 deletions interfaces/vfs/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ VFS_EXTERN bool CC VPathIsFSCompatible ( const VPath * self );
*/
VFS_EXTERN bool CC VPathFromUri ( const VPath * self );

/* IsRemote
* asks if the path is remote, not local
*/
VFS_EXTERN bool CC VPathIsRemote(const VPath * self);


/* MarkHighReliability
* mark a path as representing either a reliable URL
Expand Down
2 changes: 0 additions & 2 deletions libs/kfg/kfg-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ struct KConfig;

extern void add_aws_nodes ( struct KConfig *self );

const char * KConfigGetNgcFile(void);

bool KConfigDisabledUserSettings(void);
bool KConfigSetUserSettingsDisabled(bool disable);

Expand Down
2 changes: 1 addition & 1 deletion libs/kfg/ngc.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <kfg/extern.h>

#include <kfg/kfg-priv.h> /* KConfigGetNgcFile */
#include <kfg/ngc.h> /* KNgcObjRelease */

#include <klib/rc.h>
Expand All @@ -43,7 +44,6 @@

#include <strtol.h>

#include "kfg-priv.h" /* KConfigGetNgcFile */
#include "ngc-priv.h"

#include <string.h>
Expand Down
8 changes: 6 additions & 2 deletions libs/kns/http-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,18 @@ rc_t KHttpFileTimedReadLocked ( const KHttpFile * self,
uint64_t pos, void * buf, size_t bsize, size_t * num_read,
struct timeout_t * tm, uint32_t * http_status )
{
rc_t rc = KLockAcquire ( self -> lock );
rc_t rc = 0;
assert(self && num_read && http_status);
rc = KLockAcquire(self->lock);
if ( rc == 0 )
{
#if SUPPORT_CHUNKED_READ
/* moved the request boundary processing here.
first, check trivial case of read beyond EOF. */
if ( pos >= self -> file_size )
if ( pos >= self -> file_size ) {
* num_read = 0;
* http_status = 200;
}
else
{
/* limit read request to amount available in file */
Expand Down
10 changes: 5 additions & 5 deletions libs/vfs/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -4083,7 +4083,7 @@ static rc_t VFSManagerResolveAcc( const VFSManager * self,
}


static rc_t VFSManagerResolveLocal( const VFSManager * self,
static rc_t VFSManagerResolveLocally( const VFSManager * self,
const char * local_path,
struct VPath ** path_to_build )
{
Expand Down Expand Up @@ -4111,7 +4111,7 @@ static rc_t VFSManagerResolvePathOrAcc( const VFSManager * self,
{
/* we can now assume that the source is a filesystem-path :
we build a new VPath and prepend with 'ncbi-file:' */
rc = VFSManagerResolveLocal( self, buffer, path_to_build );
rc = VFSManagerResolveLocally( self, buffer, path_to_build );
}
else if ( resolve_acc )
{
Expand All @@ -4120,7 +4120,7 @@ static rc_t VFSManagerResolvePathOrAcc( const VFSManager * self,
if ( GetRCState( rc ) == rcNotFound )
{
/* if we were not able to find the source as accession, we assume it is a local path */
rc = VFSManagerResolveLocal( self, buffer, path_to_build );
rc = VFSManagerResolveLocally( self, buffer, path_to_build );
}
}
else
Expand All @@ -4132,7 +4132,7 @@ static rc_t VFSManagerResolvePathOrAcc( const VFSManager * self,
}


static rc_t VFSManagerResolveRemote( const VFSManager * self,
static rc_t VFSManagerResolveRemotely( const VFSManager * self,
struct VPath ** source,
struct VPath ** path_to_build,
const struct KFile ** remote_file,
Expand Down Expand Up @@ -4216,7 +4216,7 @@ LIB_EXPORT rc_t CC VFSManagerResolveSpec ( const VFSManager * self,

case vpuri_http : /* !! fall through !! */
case vpuri_https:
case vpuri_ftp : rc = VFSManagerResolveRemote( self, &temp, path_to_build, remote_file, local_cache );
case vpuri_ftp : rc = VFSManagerResolveRemotely( self, &temp, path_to_build, remote_file, local_cache );
break;

case vpuri_ncbi_legrefseq: /* ??? */
Expand Down
25 changes: 15 additions & 10 deletions libs/vfs/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -2668,6 +2668,20 @@ LIB_EXPORT bool CC VPathFromUri ( const VPath * self )
}


LIB_EXPORT bool CC VPathIsRemote(const VPath * self) {
if (self == NULL)
return false;
else if (VPathFromUri(self))
return true;
else if (VPathIsFSCompatible(self))
return false;
else {
assert(0);
return false;
}
}


/* Read*
* read the various parts
* copies out data into user-supplied buffer
Expand Down Expand Up @@ -3938,16 +3952,7 @@ rc_t LegacyVPathResolveAccession ( VFSManager * aMgr,
rc = VFSManagerMake ( & mgr );
if ( rc == 0 )
{
VResolver * resolver;
rc = VFSManagerGetResolver ( mgr, & resolver );
if ( rc == 0 )
{
rc = VResolverLocal ( resolver, path, ( const VPath** ) new_path );
if ( GetRCState ( rc ) == rcNotFound )
rc = VResolverRemote ( resolver, 0, path, ( const VPath** ) new_path );

VResolverRelease ( resolver );
}
rc = VFSManagerResolveVPath(mgr, path, (const VPath**)new_path);

if (aMgr == NULL)
VFSManagerRelease ( mgr );
Expand Down
2 changes: 1 addition & 1 deletion libs/vfs/remote-services.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include <kfg/config.h> /* KConfigRelease */
#include <kfg/kart-priv.h> /* KartItemMake2 */
#include <kfg/kfg-priv.h> /* KConfigGetNgcFile */
#include <kfg/properties.h> /* KConfig_Get_User_Accept_Aws_Charges */
#include <kfg/repository.h> /* KRepositoryMgrRelease */

Expand All @@ -61,7 +62,6 @@
#include <vfs/manager-priv.h> /* VFSManagerMakeFromKfg */
#include <vfs/services.h> /* KServiceMake */

#include "../kfg/kfg-priv.h" /* KConfigGetNgcFile */
#include "../kns/mgr-priv.h" /* KNSManagerGetCloudLocation */
#include "json-response.h" /* Response4 */
#include "jwt.h" /* JwtKartValidateFile */
Expand Down
Loading