Skip to content

Commit

Permalink
update prune files and removed findOneByName
Browse files Browse the repository at this point in the history
  • Loading branch information
LucianoPierdona committed Aug 16, 2022
1 parent c0d1fc4 commit 17069f9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
7 changes: 2 additions & 5 deletions apps/meteor/app/lib/server/functions/cleanRoomHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,12 @@ export const cleanRoomHistory = function ({

let fileCount = 0;
Messages.findFilesByRoomIdPinnedTimestampAndUsers(rid, excludePinned, ignoreDiscussion, ts, fromUsers, ignoreThreads, {
fields: { 'file._id': 1, 'file.name': 1, 'pinned': 1 },
fields: { 'pinned': 1, 'files': 1 },
limit,
}).forEach((document: IMessage) => {
const thumbName = `thumb-${document.file?.name}`;

const uploadsStore = FileUpload.getStore('Uploads');

uploadsStore.deleteById(document.file?._id);
uploadsStore.deleteByName(thumbName);
document.files?.forEach(file => uploadsStore.deleteById(file._id));
fileCount++;
if (filesOnly) {
Messages.update({ _id: document._id }, { $unset: { file: 1 }, $set: { attachments: [{ color: '#FD745E', text }] } });
Expand Down
4 changes: 0 additions & 4 deletions apps/meteor/server/models/raw/Uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,4 @@ export class UploadsRaw extends BaseRaw<IUpload> implements IUploadsModel {
async deleteFile(fileId: string): Promise<DeleteResult> {
return this.deleteOne({ _id: fileId });
}

async findOneByName(name: string): Promise<IUpload | null> {
return this.findOne({ name });
}
}
1 change: 0 additions & 1 deletion packages/model-typings/src/models/IUploadsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ export interface IUploadsModel extends IBaseModel<IUpload> {

deleteFile(fileId: string): Promise<DeleteResult>;

findOneByName(name: string): Promise<IUpload | null>;
}

0 comments on commit 17069f9

Please sign in to comment.