Skip to content

Commit

Permalink
fix(linux-file.service): fix block size confusion
Browse files Browse the repository at this point in the history
YAY, FINALLY
  • Loading branch information
zaldih committed Jan 18, 2020
1 parent d4b80fd commit cdab878
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/services/linux-files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,22 @@ import { FileService } from './files.service';
import { IListDirParams } from '../interfaces/list-dir-params.interface';
import { Observable } from 'rxjs';
import { StreamService } from './stream.service';
import { map } from 'rxjs/operators';

export class LinuxFilesService extends FileService {
constructor(private streamService: StreamService) {
super();
}

getFolderSize(path: string): Observable<{}> {
const du = spawn('du', ['-s', path]);
const du = spawn('du', ['-s', '-b', path]);
const cut = spawn('cut', ['-f', '1']);

du.stdout.pipe(cut.stdin);

return this.streamService.getStream(cut);
return this.streamService
.getStream(cut)
.pipe(map(size => super.convertBytesToKb(+size)));
}

listDir(params: IListDirParams): Observable<{}> {
Expand Down

0 comments on commit cdab878

Please sign in to comment.