Skip to content

Commit

Permalink
📁 Fixed drive item versions not working with cassandra (#2715)
Browse files Browse the repository at this point in the history
  • Loading branch information
rezk2ll authored Feb 3, 2023
1 parent 062824c commit d2ba9bf
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Column, Entity } from "../../../core/platform/services/database/service
export const TYPE = "drive_file_versions";

@Entity(TYPE, {
primaryKey: [["file_id"], "id"],
primaryKey: [["drive_item_id"], "id"],
type: TYPE,
})
export class FileVersion {
Expand All @@ -17,8 +17,8 @@ export class FileVersion {
provider: "internal" | "drive" | string;

@Type(() => String)
@Column("file_id", "uuid")
file_id: string;
@Column("drive_item_id", "uuid")
drive_item_id: string;

@Column("file_metadata", "encoded_json")
file_metadata: DriveFileMetadata;
Expand Down
6 changes: 3 additions & 3 deletions twake/backend/node/src/services/documents/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class DocumentsService {
: (
await this.fileVersionRepository.find(
{
file_id: entity.id,
drive_item_id: entity.id,
},
{},
context,
Expand Down Expand Up @@ -236,7 +236,7 @@ export class DocumentsService {
);

await this.repository.save(driveItem);
driveItemVersion.file_id = driveItem.id;
driveItemVersion.drive_item_id = driveItem.id;

await this.fileVersionRepository.save(driveItemVersion);
driveItem.last_version_cache = driveItemVersion;
Expand Down Expand Up @@ -463,7 +463,7 @@ export class DocumentsService {
//Delete the version and stored file
const itemVersions = await this.fileVersionRepository.find(
{
file_id: item.id,
drive_item_id: item.id,
},
{},
context,
Expand Down
2 changes: 1 addition & 1 deletion twake/backend/node/src/services/documents/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const getDefaultDriveItemVersion = (
creator_id: version.creator_id || context.user?.id,
data: version.data || {},
date_added: version.date_added || new Date().getTime(),
file_id: version.file_id || "",
drive_item_id: version.drive_item_id || "",
file_metadata: version.file_metadata || {},
file_size: version.file_size || 0,
filename: version.filename || "",
Expand Down
2 changes: 1 addition & 1 deletion twake/backend/node/src/services/documents/web/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fileVersionSchema = {
properties: {
id: { type: "string" },
provider: { type: "string" },
file_id: { type: "string" },
drive_item_id: { type: "string" },
file_metadata: {
type: "object",
properties: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const useDriveUpload = () => {
callback: async (file, context) => {
if (file) {
const version = {
file_id: context.id,
drive_item_id: context.id,
provider: 'internal',
application_id: '',
file_metadata: {
Expand Down
2 changes: 1 addition & 1 deletion twake/frontend/src/app/features/drive/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type DriveItemVersion = {

//The file itself, using the existing new node "file" entity
provider: string | 'drive' | 'internal'; //Equivalent to "source" in twake/backend/node/src/services/messages/entities/message-files.ts
file_id: string;
drive_item_id: string;
file_metadata: FileMetadata; //New field

date_added: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const VersionModalContent = ({ id }: { id: string }) => {
<BaseSmall>{formatBytes(version.file_metadata.size || 0)}</BaseSmall>
</div>
<div className="shrink-0 ml-4">
<Button theme="outline" onClick={() => download(id, version.file_id)}>
<Button theme="outline" onClick={() => download(id, version.drive_item_id)}>
Download
</Button>
</div>
Expand Down

0 comments on commit d2ba9bf

Please sign in to comment.