@@ -218,7 +218,7 @@ export class FileState {
218218
219219 this . viewId = viewId
220220 this . path = path
221- this . getNewFS ( path )
221+ this . getNewFS ( path , '' )
222222 }
223223
224224 private saveContext ( ) : void {
@@ -250,10 +250,12 @@ export class FileState {
250250 this . reload ( )
251251 }
252252
253- private getNewFS ( path : string , skipContext = false ) : Fs {
254- const newfs = getFS ( path )
253+ private getNewFS ( path : string , newDir : string , skipContext = false ) : Fs {
254+ const newfs = getFS ( path , newDir )
255255
256- if ( newfs ) {
256+ // only create a new FS if supported FS is different
257+ // than current one
258+ if ( ! this . fs || newfs . name !== this . fs . name ) {
257259 ! skipContext && this . api && this . saveContext ( )
258260
259261 // we need to free events in any case
@@ -526,13 +528,15 @@ export class FileState {
526528 }
527529
528530 cd ( path : string , path2 = '' , skipHistory = false , skipContext = false ) : Promise < string > {
529- // first updates fs (eg. was local fs, is now ftp)
530- if ( this . path !== path ) {
531- if ( this . getNewFS ( path , skipContext ) ) {
531+ // Since we may change Fs in the middle of a path (for example:
532+ // path == '/foo/archive/zip', path2 == '..', fs == FsZip)
533+ // In this particular case, going up a directory should
534+ // switch to FsLocal.
535+ if ( this . path !== path || path2 === '..' ) {
536+ if ( this . getNewFS ( path , path2 , skipContext ) ) {
532537 this . server = this . fs . serverpart ( path )
533538 this . credentials = this . fs . credentials ( path )
534539 } else {
535- // this.navHistory(0);
536540 return Promise . reject ( {
537541 message : i18n . i18next . t ( 'ERRORS.CANNOT_READ_FOLDER' , { folder : path } ) ,
538542 code : 'NO_FS' ,
@@ -659,7 +663,6 @@ export class FileState {
659663 }
660664
661665 openDirectory ( file : { dir : string ; fullname : string } ) : Promise < string | void > {
662- console . log ( file . dir , file . fullname )
663666 return this . cd ( file . dir , file . fullname )
664667 }
665668
0 commit comments