Add tests for client (#33)
* fix(fs/local): force closing fds and add backoffs, unit tests * test(client/web): add unit tests
This commit is contained in:
parent
1ff1e2024e
commit
ea3400aca6
12 changed files with 301 additions and 70 deletions
|
@ -99,6 +99,16 @@ func (fs *LocalFS) translate(name string) (string, error) {
|
|||
}
|
||||
|
||||
func (fs *LocalFS) Create(path string) error {
|
||||
fs.opensMtx.Lock()
|
||||
defer fs.opensMtx.Unlock()
|
||||
if len(fs.opens) > fs.opensLimit {
|
||||
err := fs.closeOpens(true, map[string]bool{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("too many opens and fail to clean: %w", err)
|
||||
}
|
||||
return ErrTooManyOpens
|
||||
}
|
||||
|
||||
fullpath, err := fs.translate(path)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -109,12 +119,6 @@ func (fs *LocalFS) Create(path string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
fs.opensMtx.Lock()
|
||||
defer fs.opensMtx.Unlock()
|
||||
if len(fs.opens) > fs.opensLimit {
|
||||
return ErrTooManyOpens
|
||||
}
|
||||
|
||||
fs.opens[fullpath] = &fileInfo{
|
||||
lastAccess: time.Now(),
|
||||
fd: fd,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue