Skip to content

Commit

Permalink
Use RLock for Truncate operation since it can be called during file a…
Browse files Browse the repository at this point in the history
…ccess
  • Loading branch information
iychoi committed Feb 26, 2022
1 parent 34840e6 commit 40d1ce0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,10 @@ func (fs *FileSystem) TruncateFile(path string, size int64) error {
irodsPath := util.GetCorrectIRODSPath(path)

// lock the file
fs.fileLocks.Lock(irodsPath)
defer fs.fileLocks.Unlock(irodsPath)
// Warning. This uses RLock since this operation can be called while a file is opened.
// (I don't know why. VIM does.)
fs.fileLocks.RLock(irodsPath)
defer fs.fileLocks.RUnlock(irodsPath)

if size < 0 {
size = 0
Expand Down

0 comments on commit 40d1ce0

Please sign in to comment.