KnpLabs/Gaufrette — pull request #202 by konradpodgorski (2013-07-22 14:34:37+00:00)
Title: Handle empty key in Filesystem

**TL;DR**

By sharing some login for create/update actions I passed null value to the delete method in local adapter which caused:

```
Warning: rmdir(/var/www/tubylo/web/uploads): Directory not empty in /var/www/tubylo/vendor/knplabs/gaufrette/src/Gaufrette/Adapter/Local.php line 128
```

Of course I didn't want to remove whole uploads directory :)
To solve this I've added additional check in assertHasFile method

end of TL;DR

**More about the problem (optional to read)**

```
# Gaufrette/Adapter/Local.php
public function exists($key)
{
return file_exists($this->computePath($key));
}
```

will always return true because computePath method

```
# Gaufrette/Adapter/Local.php
protected function computePath($key)
{
$this->ensureDirectoryExists($this->directory, $this->create);

return $this->normalizePath($this->directory . '/' . $key);
}
```
makes sure that directory exists by calling

```
$this->ensureDirectoryExists($this->directory, $this->create);
```

This leads computePath method to return e.g.
```
/var/www/foo/bar/web/uploads
```

which is perfectly fine for file_exists function

but not what we expected