2.0.x fixes

This commit is contained in:
2025-02-13 11:55:03 -06:00
parent f0a6db2266
commit a4c7e699e1
12 changed files with 108 additions and 334 deletions

View File

@@ -1,6 +1,7 @@
# About
`repertory-js` is a Node.js module for interfacing with `repertory's` remote mount API.
`repertory-js` is a Node.js module for interfacing with `repertory's` remote
mount API.
## Installing
@@ -10,43 +11,44 @@ npm i @blockstorage/repertory-js
## Repertory Configuration
A Repertory mount must be active with the `EnableRemoteMount` setting enabled. `RemoteToken` should
also be set to a strong, random password.
A Repertory mount must be active with the `RemoteMount.Enable` setting enabled.
`RemoteMount.EncryptionToken` should also be set to a strong, random password.
### Enabling Sia Remote Mount API on Windows Systems
```shell
repertory.exe -unmount
repertory.exe -set RemoteMount.EnableRemoteMount true
repertory.exe -set RemoteMount.RemoteToken "my password"
repertory.exe -set RemoteMount.Enable true
repertory.exe -set RemoteMount.EncryptionToken 'my password'
[Optional - change listening port]
repertory.exe -set RemoteMount.RemotePort 20202
repertory.exe -set RemoteMount.ApiPort 20202
```
### Enabling Sia Remote Mount API on *NIX Systems
```shell
./repertory -unmount
./repertory -set RemoteMount.EnableRemoteMount true
./repertory -set RemoteMount.RemoteToken "my password"
./repertory -set RemoteMount.Enable true
./repertory -set RemoteMount.EncryptionToken 'my password'
[Optional - change listening port]
./repertory -set RemoteMount.RemotePort 20202
./repertory -set RemoteMount.ApiPort 20202
```
### Skynet and ScPrime Mounts
### S3 Mounts
* For Skynet mounts, add `-sk` argument to all commands listed above.
* For ScPrime mounts, add `-sp` argument to all commands listed above.
* For S3 mounts, add `-s3` and `--name '<my config name>'` argument to all
commands listed above.
## Module Environment Variables
* To successfully complete unit tests, a `repertory` mount supporting remote mount needs to be
active. Set the following environment variables prior to running tests:
* `TEST_HOST`
* `TEST_PASSWORD`
* `TEST_PORT`
* To successfully complete unit tests, a `repertory` mount supporting remote
mount needs to be active. Set the following environment variables prior to
running tests:
* `TEST_HOST`
* `TEST_PASSWORD`
* `TEST_PORT`
## Example API Usage
@@ -58,7 +60,7 @@ import * as rep from "@blockstorage/repertory-js";
// Repertory host settings
const MY_HOST_OR_IP = 'localhost';
const MY_PORT = 20000;
const MY_TOKEN = 'password';
const MY_PASSWORD = 'password';
// Progress callback for uploads / downloads
const progress_cb = (local_path, remote_path, progress, completed) => {
@@ -66,33 +68,29 @@ const progress_cb = (local_path, remote_path, progress, completed) => {
};
//************************************************************************************************//
// Step 1. Create a connection pool (recommended) //
//************************************************************************************************//
const conn = await rep.create_pool(8, MY_HOST_OR_IP, MY_PORT, MY_TOKEN);
/* Or create a single connection for light operations
//****************************************************************************//
// Step 1. Create a connection //
//****************************************************************************//
const conn = await rep.connect(MY_HOST_OR_IP, MY_PORT, MY_TOKEN);
*/
/* Disconnect when complete
await conn.disconnect();
*/
//************************************************************************************************//
// Step 2. Create an 'api' instance using the connection pool / connection //
//************************************************************************************************//
//****************************************************************************//
// Step 2. Create an 'api' instance using the connection //
//****************************************************************************//
const api = rep.create_api(conn);
//************************************************************************************************//
// Step 3. Use 'api' //
//************************************************************************************************//
//****************************************************************************//
// Step 3. Use 'api' //
//****************************************************************************//
//------------------------------------------------------------------------------------------------//
// *********** Directory Operations *********** //
//------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// *********** Directory Operations *********** //
//----------------------------------------------------------------------------//
// Check if directory exists
const exists = await api.directory.exists('/my_directory');
@@ -125,9 +123,9 @@ await api.directory.create('/test');
await api.directory.remove('/test')
//------------------------------------------------------------------------------------------------//
// *********** File Operations *********** //
//------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// *********** File Operations *********** //
//----------------------------------------------------------------------------//
// Check if file exists
const exists = await api.file.exists('/my_file.txt')
@@ -154,9 +152,9 @@ await api.file.upload('C:\\my_file.txt', '/my_file.txt', progress_cb, true);
await api.file.upload('C:\\my_file.txt', '/my_file.txt', progress_cb, false, true);
//------------------------------------------------------------------------------------------------//
// *********** Low-Level File Operations *********** //
//------------------------------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
// *********** Low-Level File Operations *********** //
//----------------------------------------------------------------------------//
// Create or open a remote file
{