Do not try locking directories

Some operations like $storage->rename() can replace a target folder with
a source folder. In such cases, the flock app must not try and lock the
folder (only file locking is supported anyway).

Backport of 7f13d3a from master