Skip to content

Commit 15b80bc

Browse files
committed
Fix: Windows - get correct file path
1 parent 176c45f commit 15b80bc

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.4.22
22

33
* Fix: deleting MyTag
4+
* Fix: Windows - get correct file path
45

56
## 0.4.21
67

angular.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"once",
5757
"rxjs",
5858
"rxjs/operators",
59-
"jszip"
59+
"jszip",
60+
"path"
6061
]
6162
},
6263
"configurations": {

src/app/util/data.service.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { LocalStorageService, LocStorageKeys } from './local-storage.service';
66
import { IsLoadingService } from '@service-work/is-loading';
77
import { MyCrypto } from './mycrypto';
88
import { Clipboard } from '@angular/cdk/clipboard';
9+
import * as path from 'path';
910

1011
import { PasswordDialogComponent } from '../shared/components/password-dialog/password-dialog.component';
1112
import { FileUpdateService } from './file-update.service';
@@ -1007,12 +1008,12 @@ export class DataService {
10071008
return this.Repos.find(x => x.id == file.repoId);
10081009
}
10091010

1010-
public GetFileName(path: string) {
1011-
return path.substring(path.lastIndexOf('/')+1);
1011+
public GetFileName(p: string) {
1012+
return p.substring(p.lastIndexOf(path.sep)+1);
10121013
}
10131014

1014-
public GetFilePath(path: string) {
1015-
return path.substring(0, path.lastIndexOf('/'));
1015+
public GetFilePath(p: string) {
1016+
return p.substring(0, p.lastIndexOf(path.sep));
10161017
}
10171018

10181019
public Debug() {
@@ -1151,8 +1152,8 @@ export class DataService {
11511152
const history = this.getLastFileHistory();
11521153
this.availableFiles = this.availableFiles.sort((a, b) => {
11531154
// put not writable repos to end
1154-
if (a.source == FileSources.GitHub && !this.GetRepoOfFile(a).isWritable) return 1;
1155-
if (b.source == FileSources.GitHub && !this.GetRepoOfFile(b).isWritable) return -1;
1155+
if (a.source == FileSources.GitHub && !this.GetRepoOfFile(a)?.isWritable) return 1;
1156+
if (b.source == FileSources.GitHub && !this.GetRepoOfFile(b)?.isWritable) return -1;
11561157

11571158
// sort according to history
11581159
let aIdx = history.findIndex(x => this.compareFiles(x, a));

0 commit comments

Comments
 (0)