How to use the @wireapp/store-engine.error.LowDiskSpaceError function in @wireapp/store-engine

To help you get started, we’ve selected a few @wireapp/store-engine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wireapp / wire-web-packages / packages / store-engine-dexie / src / index.ts View on Github external
private async hasEnoughQuota(): Promise {
    if ('storage' in navigator && 'estimate' in navigator.storage) {
      const {quota, usage} = await navigator.storage.estimate();

      if (typeof quota === 'number' && typeof usage === 'number') {
        const diskIsFull = usage >= quota;
        if (diskIsFull) {
          const errorMessage = `Out of disk space. Using "${usage}" out of "${quota}" bytes.`;
          return Promise.reject(new StoreEngineError.LowDiskSpaceError(errorMessage));
        }
      }
    }

    return Promise.resolve();
  }
github wireapp / wire-web-packages / packages / store-engine-dexie / src / index.ts View on Github external
private mapDatabaseError(error: Dexie.DexieError, tableName: string, primaryKey: string): Error {
    const isAlreadyExisting = error instanceof Dexie.ConstraintError;
    /** @see https://github.com/dfahlander/Dexie.js/issues/776 */
    const hasNotEnoughDiskSpace =
      error.name === Dexie.errnames.QuotaExceeded || (error.inner && error.inner.name === Dexie.errnames.QuotaExceeded);

    if (isAlreadyExisting) {
      const message = `Record "${primaryKey}" already exists in "${tableName}". You need to delete the record first if you want to overwrite it.`;
      return new StoreEngineError.RecordAlreadyExistsError(message);
    } else if (hasNotEnoughDiskSpace) {
      const message = `Cannot save "${primaryKey}" in "${tableName}" because there is low disk space.`;
      return new StoreEngineError.LowDiskSpaceError(message);
    } else {
      return error;
    }
  }
}
github wireapp / wire-web-packages / packages / store-engine-dexie / src / index.ts View on Github external
private async hasEnoughQuota(): Promise {
    if ('storage' in navigator && 'estimate' in navigator.storage) {
      const {quota, usage} = await navigator.storage.estimate();

      if (typeof quota === 'number' && typeof usage === 'number') {
        const diskIsFull = usage >= quota;
        if (diskIsFull) {
          const errorMessage = `Out of disk space. Using "${usage}" out of "${quota}" bytes.`;
          throw new StoreEngineError.LowDiskSpaceError(errorMessage);
        }
      }
    }
  }
github wireapp / wire-web-packages / packages / store-engine-dexie / src / index.ts View on Github external
private mapDatabaseError(
    error: Dexie.DexieError,
    tableName: string,
    primaryKey: PrimaryKey,
  ): Error {
    const isAlreadyExisting = error instanceof Dexie.ConstraintError;
    /** @see https://github.com/dfahlander/Dexie.js/issues/776 */
    const hasNotEnoughDiskSpace =
      error.name === Dexie.errnames.QuotaExceeded || error.inner?.name === Dexie.errnames.QuotaExceeded;

    if (isAlreadyExisting) {
      const message = `Record "${primaryKey}" already exists in "${tableName}". You need to delete the record first if you want to overwrite it.`;
      return new StoreEngineError.RecordAlreadyExistsError(message);
    } else if (hasNotEnoughDiskSpace) {
      const message = `Cannot save "${primaryKey}" in "${tableName}" because there is low disk space.`;
      return new StoreEngineError.LowDiskSpaceError(message);
    } else {
      return error;
    }
  }