Skip to content

Commit

Permalink
Add COMPRESSION_REMOTE, do avoid downloading remote files unless requ…
Browse files Browse the repository at this point in the history
…ested in the filebrowser.
  • Loading branch information
mywave82 committed Oct 21, 2024
1 parent 507aea2 commit 71580bf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
13 changes: 13 additions & 0 deletions filesel/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,15 @@ typedef void *ocpdirhandle_pt;
#define COMPRESSION_SOLID2 5 /* ... */
#define COMPRESSION_SOLID3 6 /* ... */
#define COMPRESSION_SOLID4 7 /* ... */
#define COMPRESSION_REMOTE 127

static inline uint8_t COMPRESSION_ADD_STORE (uint8_t parent)
{
uint8_t retval = (parent >= COMPRESSION_STREAM) ? parent+1 : parent | 1;
if (parent == COMPRESSION_REMOTE)
{
return COMPRESSION_REMOTE;
}
if (retval > COMPRESSION_SOLID4)
{
retval = COMPRESSION_SOLID4;
Expand All @@ -35,6 +40,10 @@ static inline uint8_t COMPRESSION_ADD_STORE (uint8_t parent)
static inline uint8_t COMPRESSION_ADD_STREAM (uint8_t parent)
{
uint8_t retval = parent + 2;
if (parent == COMPRESSION_REMOTE)
{
return COMPRESSION_REMOTE;
}
if (retval > COMPRESSION_SOLID4)
{
retval = COMPRESSION_SOLID4;
Expand All @@ -44,6 +53,10 @@ static inline uint8_t COMPRESSION_ADD_STREAM (uint8_t parent)
static inline uint8_t COMPRESSION_ADD_SOLID (uint8_t parent)
{
uint8_t retval = parent + 3;
if (parent == COMPRESSION_REMOTE)
{
return COMPRESSION_REMOTE;
}
if (retval > COMPRESSION_SOLID4)
{
retval = COMPRESSION_SOLID4;
Expand Down
17 changes: 12 additions & 5 deletions filesel/pfilesel.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static void fsReadDir_file (void *_token, struct ocpfile_t *file)
if (ismod || // always include if file is an actual module
(fsShowAllFiles && (!(token->opt & RD_ISMODONLY)))) // force include if fsShowAllFiles is true, except if RD_ISMODONLY
{
modlist_append_file (token->ml, file, ismod, file->compression >= COMPRESSION_SOLID); /* modlist_append() will do refcount on the file */
modlist_append_file (token->ml, file, ismod, file->compression >= COMPRESSION_SOLID && (file->compression < COMPRESSION_REMOTE)); /* modlist_append() will do refcount on the file */
}
out:
free (curext);
Expand Down Expand Up @@ -3297,7 +3297,7 @@ signed int fsFileSelect(void)
if (!Console.KeyboardHit() && fsScanNames)
{
int poll = 1;
if ((m->file && (m->flags & MODLIST_FLAG_ISMOD)) && (!mdbInfoIsAvailable(m->mdb_ref)) && (!(m->flags&MODLIST_FLAG_SCANNED)))
if ((m->file && (m->file->compression < COMPRESSION_REMOTE) && (m->flags & MODLIST_FLAG_ISMOD)) && (!mdbInfoIsAvailable(m->mdb_ref)) && (!(m->flags&MODLIST_FLAG_SCANNED)))
{
mdbScan(m->file, m->mdb_ref);
m->flags |= MODLIST_FLAG_SCANNED;
Expand All @@ -3308,7 +3308,7 @@ signed int fsFileSelect(void)
struct modlistentry *scanm;
if ((scanm=modlist_get(currentdir, scanposf++)))
{
if (scanm->file && (scanm->flags & MODLIST_FLAG_ISMOD) && (!(scanm->flags & MODLIST_FLAG_SCANNED)))
if (scanm->file && (scanm->file->compression < COMPRESSION_REMOTE) && (scanm->flags & MODLIST_FLAG_ISMOD) && (!(scanm->flags & MODLIST_FLAG_SCANNED)))
{
if (!mdbInfoIsAvailable(scanm->mdb_ref))
{
Expand All @@ -3329,7 +3329,7 @@ signed int fsFileSelect(void)
struct modlistentry *scanm;
if ((scanm=modlist_get(playlist, scanposp++)))
{
if (scanm->file && (scanm->flags & MODLIST_FLAG_ISMOD))
if (scanm->file && (scanm->file->compression < COMPRESSION_REMOTE) && (scanm->flags & MODLIST_FLAG_ISMOD))
{
if (!mdbInfoIsAvailable(scanm->mdb_ref))
{
Expand Down Expand Up @@ -3470,7 +3470,8 @@ signed int fsFileSelect(void)
mdbEditBuf.modtype.integer.i = mtUnRead;
if (!mdbWriteModuleInfo(m->mdb_ref, &mdbEditBuf))
return -1;
m->flags &= ~MODLIST_FLAG_SCANNED;
mdbScan(m->file, m->mdb_ref);
m->flags |= MODLIST_FLAG_SCANNED;
}
break;
case KEY_CTRL_BS:
Expand Down Expand Up @@ -3535,6 +3536,12 @@ signed int fsFileSelect(void)
break;
}
}
/* We delay mdbScan for remote files until this stage */
if (m && m->file && (m->file->compression >= COMPRESSION_REMOTE) && !(m->flags & MODLIST_FLAG_SCANNED))
{
mdbScan (m->file, m->mdb_ref);
m->flags |= MODLIST_FLAG_SCANNED;
}
if (win)
{
if (!playlist->num)
Expand Down

0 comments on commit 71580bf

Please sign in to comment.