How to use get-folder-size - 8 common examples

To help you get started, we’ve selected a few get-folder-size 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 beakerbrowser / beaker / app / background-process / networks / dat.js View on Github external
archive.open(() => {

    // read the archive metafiles
    readManifest(archive, done())
    readVFile(archive, done())

    // calculate the size on disk
    var sizeCb = done()
    getFolderSize(ARCHIVE_FILEPATH(archive), (err, size) => {
      sizeCb(null, size)
    })

    done((err, manifest, vfile, size) => {
      manifest = manifest || {}
      var { name, description, author, homepage_url } = manifest
      var version = (vfile) ? vfile.current : false
      var mtime = Date.now() // use our local update time
      size = size || 0

      // write the record
      var update = { name, description, author, homepage_url, version, mtime, size }
      log('[DAT] Writing meta', update)
      archiveMetaDb.put(key, update, err => {
        if (err)
          log('[DAT] Error while writing archive meta', key, err)
github beakerbrowser / beaker / app / background-process / networks / dat / dat.js View on Github external
archive.open(() => {
    // read the archive metafiles
    pda.readManifest(archive, done())

    // calculate the size on disk
    var sizeCb = done()
    getFolderSize(archivesDb.getArchiveFilesPath(archive), (_, size) => {
      sizeCb(null, size)
    })

    done((_, manifest, size) => {
      manifest = manifest || {}
      var { title, description, author, version, forkOf, createdBy } = manifest
      var mtime = Date.now() // use our local update time
      var isOwner = archive.owner
      size = size || 0

      // write the record
      var update = { title, description, author, version, forkOf, createdBy, mtime, size, isOwner }
      debug('Writing meta', update)
      archivesDb.setArchiveMeta(key, update).then(
        () => {
          update.key = key
github electrode-io / electrode-native / ern-core / src / FsCache.ts View on Github external
new Promise((resolve, reject) => {
    getSize(dirPath, (err, size) => {
      err ? reject(err) : resolve(size)
    })
  })
github jakoblo / ufo / src / js / filesystem / write / child-worker / fs-write-worker-copy.js View on Github external
return new Promise((resolve, reject) => {
    getSize(subTask.source, (err, size) => {
      if (err) {
        reject(err);
        return;
      }
      fullSize = size;
      ncp(subTask.source, subTask.destination, ncpOptions, errList => {
        if (errList) {
          reject(errList[0]);
          return;
        }
        resolve();
      });
    });
  });
}
github ififfy / flipflip / src / renderer / data / actions.ts View on Github external
const buffer = Buffer.alloc(arrayBuffer.byteLength);
                  const view = new Uint8Array(arrayBuffer);
                  for (let i = 0; i < arrayBuffer.byteLength; ++i) {
                    buffer[i] = view[i];
                  }
                  outputFile(filePath, buffer);
                }
              };
              reader.readAsArrayBuffer(blob);
            });
        }
      };
      if (maxSize == 0) {
        downloadImage();
      } else {
        getFolderSize(cachePath, (err: string, size: number) => {
          if (err) {
            throw err;
          }

          const mbSize = (size / 1024 / 1024);
          if (mbSize < maxSize) {
            downloadImage();
          }
        });
      }
    }
  }
}
github aragon / aragon-cli / packages / toolkit / src / ipfs / config.js View on Github external
return new Promise((resolve, reject) => {
    getFolderSize(repoPath, (err, size) => {
      if (err) {
        reject(err)
      } else {
        const humanReadableSize = byteSize(size)
        resolve(humanReadableSize)
      }
    })
  })
}
github MichaelMure / Arbore / app / components / sharing / ContentInput.js View on Github external
        ? new Promise((resolve, reject) => { getFolderSize(path, (err, total) => err ? reject(err) : resolve(total)) })
        : Promise.resolve(stat.size)
github ififfy / flipflip / src / renderer / components / config / CacheGroup.tsx View on Github external
calculateCacheSize() {
    if (this.props.config.caching.maxSize != 0) {
      const cachePath = getCachePath(null, this.props.config);
      if (existsSync(cachePath)) {
        getFolderSize(getCachePath(null, this.props.config), (err: string, size: number) => {
          if (err) { throw err; }
          const mbSize = (size / 1024 / 1024);
          this.setState({cacheSize: mbSize.toFixed(2) + "MB"});
        });
      }
    }
  }

get-folder-size

Get the size of a folder by iterating through its sub-files and -folders.

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis

Popular get-folder-size functions