Skip to content

Commit

Permalink
[PB-1933] fix: show only overriden file as uploaded (internxt#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanVicens authored Mar 28, 2024
1 parent be7d971 commit 01ad139
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/apps/fuse/callbacks/UploadOnRename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ export class UploadOnRename {
await this.offline.offlineContentsUploader.run(
offlineFile.id,
offlineFile.path,
fileToOverride.contentsId
{
contentsId: fileToOverride.contentsId,
name: fileToOverride.name,
extension: fileToOverride.type,
}
);

return right(UploadOnRename.SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import { FilePath } from '../../../virtual-drive/files/domain/FilePath';
import { OfflineContentsName } from '../domain/OfflineContentsName';
import Logger from 'electron-log';

interface Replaces {
contentsId: string;
name: string;
extension: string;
}

export class OfflineContentsUploader {
constructor(
private readonly repository: OfflineContentsRepository,
Expand All @@ -16,7 +22,7 @@ export class OfflineContentsUploader {
async run(
name: OfflineContentsName,
path: FilePath,
replaces?: string
replaces?: Replaces
): Promise<string> {
const { contents, stream, abortSignal } =
await this.repository.createStream(name);
Expand All @@ -25,8 +31,8 @@ export class OfflineContentsUploader {
stream,
contents,
{
name: path.name(),
extension: path.extension(),
name: replaces?.name || path.name(),
extension: replaces?.extension || path.extension(),
},
abortSignal
);
Expand All @@ -40,7 +46,7 @@ export class OfflineContentsUploader {
offlineContentsPath: contents.absolutePath,
size: contents.size,
path: path.value,
replaces,
replaces: replaces?.contentsId,
});

await this.eventBus.publish([contentsUploadedEvent]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fs, { closeSync, createReadStream, readSync, unlink, watch } from 'fs';
import fs, { createReadStream, unlink, watch } from 'fs';
import { readFile, stat as statPromises } from 'fs/promises';
import { OfflineContentsRepository } from '../domain/OfflineContentsRepository';
import { OfflineFile } from '../../files/domain/OfflineFile';
import { LocalFileContentsDirectoryProvider } from '../../../virtual-drive/shared/domain/LocalFileContentsDirectoryProvider';
import { basename, dirname, join } from 'path';
import Logger from 'electron-log';
import { Readable, Stream } from 'stream';
import { Readable } from 'stream';
import { OfflineContents } from '../domain/OfflineContents';
import { OfflineContentsName } from '../domain/OfflineContentsName';
import { OfflineFileId } from '../../files/domain/OfflineFileId';
Expand Down

0 comments on commit 01ad139

Please sign in to comment.