pnp / powershell

PnP PowerShell
https://pnp.github.io/powershell
MIT License
621 stars 331 forks source link

[BUG] Copy-PnPFile or Copy-PnPFolder not waiting for the all the operation #3078

Open EnmanuelParedesR opened 1 year ago

EnmanuelParedesR commented 1 year ago

Notice

Many bugs reported are actually related to the PnP Framework which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Invoke-PnPSiteTemplate or Get-PnPSiteTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/pnp/pnpframework/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/pnp/powershell/tree/master/src/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/pnp/pnpframework/issues

Reporting an Issue or Missing Feature

When using Copy-PnPFile or Copy-PnPFolder the command is returns as soon as the folder is created and all the files inside of it are being created in a background progress (this is without using the -NoWait argument)

Example:


Copy-PnPFile -SourceUrl $file["FileRef"] -TargetUrl $destinationFileUrl  -Connection $connectionDestination -Force

This is on a folder, and the process end and keeps creating all the files inside of it

Expected behavior

The command should end when all the files inside of it (in the case of the folder) finish.

Actual behavior

As I can see as soon as the folder item is created the operation return

Steps to reproduce behavior

What is the version of the Cmdlet module you are running?

(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable)

Version 1.12.0

Which operating system/environment are you running PnP PowerShell on?

EnmanuelParedesR commented 1 year ago

Other stuff to mention is that Copy-PnPFile or Folder should be able to create the folders that it needs if is an item

For example: 'Documents/TestFolder/TestFile.txt' to 'Documents2/TestFolder' should create the folder "TestFolder" if it does not exist in the destination, this way we prevent to create a logic for the folders operation.

I feel like I accomplish this with a lower version of PnP, but I don't know if I set the operation on the folder