sftp-cache
Cache via sftp. Supports caching files and redownloading them
Last updated 10 days ago by axe312 .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install sftp-cache 
SYNC missed versions from official npm registry.

SFTP-CACHE

npm npm

Maintainability Contributor Covenant

Use a directory on any ssh/sftp enabled server as a cache directory.

The main goal is to allow caching of heavy project assets like videos to avoid unnecessary reconversions while deploying.

Features

  • Download from cache directory and refill it again
  • Compare file by missing on other end, modification date, file size and md5 hash
  • Keeps file modification date
  • Client: Windows, Linux, OSX
  • Server: Any host supporting sftp. MD5 hash comparision also needs md5 or md5sum installed on the server.

Installation

npm i sftp-cache

Usage

const { join } = require('path')

const sftpCache = require('sftp-cache')

;(async () => {
  try {
    await sftpCache({
      connection: {
        // All options: https://github.com/mscdex/ssh2#client-methods
        host: 'your.host.io',
        username: 'your-sft-user',
        password: '5up3r53cr37Pa$$w0rd'
        // Please do not store your credentials in your code. You can use environment variables & https://www.npmjs.com/package/dotenv
      },
      localDir: join(__dirname, 'assets'),
      remoteDir: '/home/your-sftp-user/sftp-cache-storage/assets',
      dirsToCache: [
        // Make sure paths are relative to localDir
        join('public', 'assets', 'videos'),
        join('node_modules', '.cache')
      ],
      // Tell it what to do:
      // cache: Uploads changed files from local to remote
      // download: Download changed files from remote to local
      syncDirection: 'cache'
    })
    console.log('success!')
  } catch (err) {
    console.log('failed!')
    console.error(err)
    process.exit(1)
  }
})()

Current Tags

  • 0.0.8                                ...           canary (a year ago)
  • 0.0.12                                ...           latest (10 days ago)

12 Versions

  • 0.0.12                                ...           10 days ago
  • 0.0.11                                ...           10 days ago
  • 0.0.10                                ...           10 days ago
  • 0.0.9                                ...           3 months ago
  • 0.0.8                                ...           a year ago
  • 0.0.7                                ...           a year ago
  • 0.0.6                                ...           a year ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 1
Last Week 24
Last Month 24
Dependencies (6)
Dev Dependencies (12)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |