Repository: PrefectHQ/prefect

Issue:
Deployment build for GCS skips loading files in 2.3.0
### First check

- [X] I added a descriptive title to this issue.
- [X] I used the GitHub search to find a similar issue and didn't find it.
- [X] I searched the Prefect documentation for this issue.
- [X] I checked that this issue is related to Prefect and not one of its dependencies.

### Bug summary

In Prefect 2.2.0 I could run prefect deployment build on a function with some files in .prefectignore file (which worked) and all of the files (except for those in .prefectignore) were uploaded to GCS. In 2.3.0 a tenth of the files are loading (~200 previously now ~20). I am running this on a Windows Machine (not sure if this is relevant or not) with Python 3.8.13. For the time being I've downgraded to 2.2.0 because of this issue. 

### Reproduction

```python
prefect deployment build  main_python_files/w_wrapper_update_data.py:wrapper_data_update_function --name Capacity --storage-block gcs/gcs-capacity-subfolder --work-queue Capacity
```


### Error

```

# Copy complete stack trace and error message here, including log output if applicable.

```


### Versions

```

Version of Prefect where the GCS remote deployment file uploading works:
(Capacity_venv) C:\Users\JKANG1\PycharmProjects\Manheim_Capacity>prefect version
Version:             2.2.0
API version:         0.8.0
Python version:      3.8.13
Git commit:          e3651362
Built:               Tue, Aug 23, 2022 2:18 PM
OS/Arch:             win32/AMD64
Profile:             new_dell
Server type:         hosted

Version of Prefect where the GCS remote deployment file uploading DOES NOT work:
(Capacity_venv) C:\Users\jkang1\PycharmProjects\Manheim_Capacity>prefect version
Version:             2.3.0
API version:         0.8.0
Python version:      3.8.13
Git commit:          8d9316c0
Built:               Tue, Aug 30, 2022 5:30 PM
OS/Arch:             win32/AMD64
Profile:             remote-desktop
Server type:         cloud


```


### Additional context

_No response_


Discussion:
Hi @johnkangw! Thanks for reporting this, and sorry it's causing you a headache. We did make some adjustments to the way file copying worked with remote file systems in 2.3, so it's not crazy that we could have a regression here.

So I can try to reproduce this, would you feel comfortable giving a directory listing of the 200 files it should be copying and the 20 files it is copying? Also could you include the contents of your `.prefectignore`?
@bunchesofdonald Sure thing. 
Folder structure:
<img width="380" alt="image" src="https://user-images.githubusercontent.com/72617548/187992669-0e0acdab-a82a-444e-a110-88bf82045935.png">

On Prefect 2.3.0:
![image](https://user-images.githubusercontent.com/72617548/187992506-60fb80bb-98db-4bda-acbd-6dba632aef85.png)
Only 20 files
![image](https://user-images.githubusercontent.com/72617548/187992747-d995478b-60b4-4de3-acaa-132f58efbc43.png)

On Prefect 2.2.0:
![image](https://user-images.githubusercontent.com/72617548/187993293-a81ad1b1-b9ac-4cc5-ad4b-71887e6b9bd1.png)
A snapshot of the 218 files uploaded to GCS:
![image](https://user-images.githubusercontent.com/72617548/187993470-e9876ed3-aa9f-486a-b926-8d0aaa5ecbcb.png)



Contents of `.prefectignore`

`
# prefect artifacts
.prefectignore

# python artifacts
__pycache__/
*.py[cod]
*$py.class
*.egg-info/
*.egg

# Type checking artifacts
.mypy_cache/
.dmypy.json
dmypy.json
.pyre/

# IPython
profile_default/
ipython_config.py
*.ipynb_checkpoints/*

# Environments
.python-version
.env
.venv
env/
venv/

# MacOS
.DS_Store

# Dask
dask-worker-space/

# Editors
.idea/
.vscode/

# Other random folders
.hypothesis/
.ipynb_checkpoints/
.pytest_cache/
.vscode/
assets/
cache-directory/
pages/
utils/
.git/

# In main_python_files
main_python_files/.hypothesis
main_python_files/.idea
main_python_files/.pytest_cache
main_python_files/G_callback_functions

# Random files
.gitignore
2.0b
2.1.1
dash_ag_grid-1.2.1.tar.gz
DOKKU_SCALE
mito-starter-notebook.ipynb
Plotly - Cox Automotive_App Review.pdf
predeploy_update_data.py
Procfile
pyanywhere.docx
requirements.txt
requirements_backup_before_shortening.txt
runtime.txt
tester.py
`
It seems like in 2.3.0 it is skipping folders embedded within the project (like all of the files within main_python_files and its subfolders. 
🤯 That's fantastic, we'll look into this and see what's going on.
@bunchesofdonald Thanks for the quick response! Looking forward to the fix in 2.4.0 or 2.3.1!

Resolving patch:
diff --git a/src/prefect/filesystems.py b/src/prefect/filesystems.py
--- a/src/prefect/filesystems.py
+++ b/src/prefect/filesystems.py
@@ -326,14 +326,14 @@ async def put_directory(
 
         counter = 0
         for f in glob.glob(os.path.join(local_path, "**"), recursive=True):
-            relative_path = PurePath(f).relative_to(local_path).as_posix()
-            if included_files and relative_path not in included_files:
+            relative_path = PurePath(f).relative_to(local_path)
+            if included_files and str(relative_path) not in included_files:
                 continue
 
             if to_path.endswith("/"):
-                fpath = to_path + relative_path
+                fpath = to_path + relative_path.as_posix()
             else:
-                fpath = to_path + "/" + relative_path
+                fpath = to_path + "/" + relative_path.as_posix()
 
             if Path(f).is_dir():
                 pass


Test patch: