Error testing existence of a directory
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 393
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 36
Description
### Which service(blob, file, queue, table) does this issue concern?
Blob
### Which version of the Azurite was used?
Built the 3.4.0 docker container from commit
### Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
Github
### What's the Node.js version?
6.13.4
### What problem was encountered?
I use the [azure-storage-blob](https://github.com/Azure/azure-storage-python) Python library to test for the existence of a "directory". Directories are referred to as BlobPrefix.
The `.exists()` method makes the following API call
`"HEAD /devstoreaccount1/files/text/ HTTP/1.1" 404 -`
Testing this on real Azure accounts the HEAD will return 202 for a valid prefix.
### Steps to reproduce the issue?
`conda create -n python=3.7 azure-storage-blob=2.1.0 azure-storage-common=2.1.0`
Run the following code
```python
from azure.storage.blob import BlockBlobService
bbs = BlockBlobService(is_emulated=True)
# create container, prefix, and blob
bbs.create_container('files')
bbs.create_blob_from_text('files', 'text/hello.txt', 'Hello, World!')
# identify the prefix
entries = [(type(b),b.name) for b in bbs.list_blobs('files', prefix='text', delimiter='/')]
print(entries)
# identify the blob
entries = [(type(b),b.name) for b in bbs.list_blobs('files', prefix='text/', delimiter='/')]
print(entries)
print(f'prefix text/ exists: {bbs.exists("files", "text/")}')
print(f'blob text/hello.txt exists: {bbs.exists("files", "text/hello.txt")}')
```
With Azurite the following output is produced
```
[(, 'text/')]
[(, 'text/hello.txt')]
prefix text/ exists: False
blob text/hello.txt exists: True
```
### Have you found a mitigation/solution?
I had a colleague test the `.exists()` function. I am setting up a real Azure account to test this myself.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.