steelbrain/node-ssh

Seek fault when downloading some files

BennyAlex opened this issue · 1 comments

I try to download a directory, for some files I get an seek faul error. Always the same files failing.

// Function to download a directory
async function backupDirectory(backupDir) {
  try {
    await sftp.connect(server);
    
    console.log('Connected to SFTP server');
    
    const failed = []
    const successful = []
    
    const status = await sftp.getDirectory(backupDir, '/0g564be4cbaMfUx3', {
      recursive: true,
      concurrency: 2,
      tick: function(localPath, remotePath, error) {
        if (error) {
          console.log(`Failed to download ${remotePath}: ${error}`);
          failed.push(localPath)
        } else {
          console.log(`Successfully downloaded ${remotePath}`);
          successful.push(localPath)
        }
      }
    });
    
    console.log('the directory transfer was', status ? 'successful' : 'unsuccessful')
    console.log('failed transfers', failed.length);
    console.log('successful transfers', successful.length);
  } catch (err) {
    console.error('SFTP error:', err);
  } finally {
    await sftp.dispose();
  }
}

Console output:

Connected to SFTP server
Failed to download \0g564be4cbaMfUx3\_foundUrlsWithoutStatus.json: Error: Seek fault.
Successfully downloaded \0g564be4cbaMfUx3\config.json
Failed to download \0g564be4cbaMfUx3\foundUrls.json: Error: Seek fault.
Successfully downloaded \0g564be4cbaMfUx3\foundUrlsHistory.json
Successfully downloaded \0g564be4cbaMfUx3\history.json
Successfully downloaded \0g564be4cbaMfUx3\pdfs.json
Successfully downloaded \0g564be4cbaMfUx3\report.json
Successfully downloaded \0g564be4cbaMfUx3\sitemap.json
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-error-error-faces-code-404.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-error-error-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-imprint-imprint-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-imprint-licenseinfo-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-imprint-privacy-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-sitemap-sitemap-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-subMenu-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-utilities-accessibilityHelp-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-utilities-accessibilityStatement-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\reports\hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-utilities-easyLanguageHelp-faces.json: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-.jpeg: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-error-error-faces-code-404.jpeg: Error: Seek fault.
Successfully downloaded \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-error-error-faces.jpeg
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-imprint-imprint-faces.jpeg: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-imprint-licenseinfo-faces.jpeg: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-imprint-privacy-faces.jpeg: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-sitemap-sitemap-faces.jpeg: Error: Seek fault.
Successfully downloaded \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-subMenu-faces.jpeg
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-utilities-accessibilityHelp-faces.jpeg: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-utilities-accessibilityStatement-faces.jpeg: Error: Seek fault.
Failed to download \0g564be4cbaMfUx3\screenshots\Full_hio-eh-prod-hispro-de-qisserver-pages-cs-sys-portal-utilities-easyLanguageHelp-faces.jpeg: Error: Seek fault.
the directory transfer was unsuccessful
failed transfers 22
successful transfers 8

Hi @BennyAlex

This is very interesting! There's a lot of potential points of failure here, from the ssh client to ssh server to the underlying filesystem itself.

Let's work together to try and eliminate the choices one by one. Is it possible to zip the files that you're trying to download (with .exec or .execCommand) and then download the zip?