Skip to content
Open
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
5 changes: 5 additions & 0 deletions ts/session/utils/AttachmentsDownload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { getAttachmentMetadata } from '../../types/message/initializeAttachmentM
import { AttachmentDownloadMessageDetails } from '../../types/sqlSharedTypes';
import { was404Error } from '../apis/snode_api/onions';
import * as Constants from '../constants';
import { skipAttachmentsDownloads } from '../../shared/env_vars';

// this may cause issues if we increment that value to > 1, but only having one job will block the whole queue while one attachment is downloading
const MAX_ATTACHMENT_JOB_PARALLELISM = 3;
Expand Down Expand Up @@ -140,6 +141,10 @@ async function _maybeStartJob() {
async function _runJob(job: any) {
const { id, messageId, attachment, type, index, attempts, isOpenGroupV2, openGroupV2Details } =
job || {};
if (skipAttachmentsDownloads()) {
await _finishJob(null, id);
return;
}
let found: MessageModel | undefined | null;
try {
if (!job || !attachment || !messageId) {
Expand Down
5 changes: 5 additions & 0 deletions ts/session/utils/job_runners/jobs/AvatarDownloadJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { processAvatarData } from '../../../../util/avatar/processAvatarData';
import { downloadAttachmentFs } from '../../../../receiver/attachments';
import { extractDetailsFromUrlFragment } from '../../../url';
import { MultiEncryptWrapperActions } from '../../../../webworker/workers/browser/libsession_worker_interface';
import { skipAttachmentsDownloads } from '../../../../shared/env_vars';

const defaultMsBetweenRetries = 10000;
const defaultMaxAttempts = 3;
Expand Down Expand Up @@ -89,6 +90,10 @@ class AvatarDownloadJob extends PersistedJob<AvatarDownloadPersistedData> {
}

public async run(): Promise<RunJobResult> {
if (skipAttachmentsDownloads()) {
return RunJobResult.Success;
}

const convoId = this.persistedData.conversationId;

window.log.debug(
Expand Down
4 changes: 4 additions & 0 deletions ts/session/utils/job_runners/jobs/AvatarMigrateJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { processAvatarData } from '../../../../util/avatar/processAvatarData';
import { DecryptedAttachmentsManager } from '../../../crypto/DecryptedAttachmentsManager';
import { IMAGE_JPEG } from '../../../../types/MIME';
import { NetworkTime } from '../../../../util/NetworkTime';
import { skipAttachmentsDownloads } from '../../../../shared/env_vars';

const defaultMsBetweenRetries = 10000;
const defaultMaxAttempts = 3;
Expand Down Expand Up @@ -85,6 +86,9 @@ class AvatarMigrateJob extends PersistedJob<AvatarMigratePersistedData> {
}

public async run(): Promise<RunJobResult> {
if (skipAttachmentsDownloads()) {
return RunJobResult.Success;
}
const convoId = this.persistedData.conversationId;

window.log.debug(`running job ${this.persistedData.jobType} with conversationId:"${convoId}"`);
Expand Down
8 changes: 8 additions & 0 deletions ts/shared/env_vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ export function isUnitTest() {
export function isDebugMode() {
return !!process.env.SESSION_DEV;
}

/**
* Returns true when any kind of avatars/attachments should not be downloaded.
* This is for our users with an issue with sharp that makes the app crashes.
*/
export function skipAttachmentsDownloads() {
return !!process.env.SESSION_SKIP_ATTACHMENTS_DOWNLOADS;
}
Loading