Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-1933] fix: show only overriden file as uploaded #478

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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