mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
handling broken directory path
This commit is contained in:
parent
62ccedcc2f
commit
6d613aa6f3
@ -21,7 +21,8 @@ export class GalleryMWs {
|
||||
const directoryName = req.params.directory || '/';
|
||||
const absoluteDirectoryName = path.join(ProjectPath.ImageFolder, directoryName);
|
||||
|
||||
if (!fs.statSync(absoluteDirectoryName).isDirectory()) {
|
||||
if (!fs.existsSync(absoluteDirectoryName) ||
|
||||
!fs.statSync(absoluteDirectoryName).isDirectory()) {
|
||||
return next();
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
|
||||
let directoryName = params['directory'];
|
||||
directoryName = directoryName || '';
|
||||
|
||||
this._galleryService.getDirectory(directoryName);
|
||||
this._galleryService.loadDirectory(directoryName);
|
||||
|
||||
|
||||
};
|
||||
|
@ -8,6 +8,7 @@ import {BehaviorSubject} from 'rxjs';
|
||||
import {SharingDTO} from '../../../common/entities/SharingDTO';
|
||||
import {Config} from '../../../common/config/public/Config';
|
||||
import {ShareService} from './share.service';
|
||||
import {NavigationService} from '../model/navigation.service';
|
||||
|
||||
@Injectable()
|
||||
export class GalleryService {
|
||||
@ -18,7 +19,8 @@ export class GalleryService {
|
||||
|
||||
constructor(private networkService: NetworkService,
|
||||
private galleryCacheService: GalleryCacheService,
|
||||
private _shareService: ShareService) {
|
||||
private _shareService: ShareService,
|
||||
private navigatoinService: NavigationService) {
|
||||
this.content = new BehaviorSubject<ContentWrapper>(new ContentWrapper());
|
||||
}
|
||||
|
||||
@ -26,7 +28,7 @@ export class GalleryService {
|
||||
directory: null
|
||||
};
|
||||
|
||||
public async getDirectory(directoryName: string): Promise<ContentWrapper> {
|
||||
public loadDirectory(directoryName: string): void {
|
||||
const content = new ContentWrapper();
|
||||
|
||||
content.directory = this.galleryCacheService.getDirectory(directoryName);
|
||||
@ -49,7 +51,7 @@ export class GalleryService {
|
||||
}
|
||||
|
||||
|
||||
const cw = await this.networkService.getJson<ContentWrapper>('/gallery/content/' + directoryName, params);
|
||||
this.networkService.getJson<ContentWrapper>('/gallery/content/' + directoryName, params).then((cw) => {
|
||||
|
||||
|
||||
if (!cw || cw.notModified === true) {
|
||||
@ -70,8 +72,9 @@ export class GalleryService {
|
||||
this.content.next(cw);
|
||||
|
||||
|
||||
return cw;
|
||||
|
||||
}).catch(() => {
|
||||
this.navigatoinService.toGallery();
|
||||
});
|
||||
}
|
||||
|
||||
public async search(text: string, type?: SearchTypes): Promise<ContentWrapper> {
|
||||
@ -105,7 +108,7 @@ export class GalleryService {
|
||||
clearTimeout(this.searchId);
|
||||
}
|
||||
if (!this.lastDirectory) {
|
||||
this.getDirectory('/');
|
||||
this.loadDirectory('/');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user