Skip to content

Cannot get progress when using push or SyncService push #16

@leifcr

Description

@leifcr

Hi

I cannot seem to successfully get the progress on a push or the syncservice push.

It seems like the promise is not returned before the push is complete or failed, resulting on the PushTransfer object being available after the promise is resolved.

Example code that works, but events are not triggered

  pushFileToDevices = async (
    device: Device,
    localFilePath: string,
    remoteFilePath: string
  ): Promise<void> => {
    try {
      const sync = await device.getClient().syncService()
      const transfer = await sync.push(localFilePath, remoteFilePath)
      transfer.on('progress', (stats) => {
        console.log(`[${device.id}] Pushed ${stats.bytesTransferred} bytes so far`)
      })
      transfer.on('end', () => {
        console.log(`[${device.id}] Push complete`)
      })
      console.log(`Pushed ${localFilePath} to ${device.id}:${remoteFilePath}`)
    } catch (err) {
      console.error(`Could not push ${localFilePath} to ${device.id}:${remoteFilePath}: ${err}`)
    }
  }

Same result when using then statement instead of awaiting the PushTransfer object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions