| 99 | file_name_(std::move(filename)) {} |
| 100 | |
| 101 | ~BaseDescriptor() { |
| 102 | VLOG(2) << "Out of scope descriptor with file name: " << filename(); |
| 103 | |
| 104 | // The destruction of the descriptor indicates that there's no active user |
| 105 | // of the file at the moment. However, if the fd is still open in the LRU |
| 106 | // cache, should we leave it there, or should we evict it? |
| 107 | // |
| 108 | // We opt for eviction: your typical filesystem user is more likely to want |
| 109 | // the underlying resource released when they're done working with a file |
| 110 | // than they are to want the resource to be quickly accessible should the |
| 111 | // file be reopened. |
| 112 | cache()->Erase(filename()); |
| 113 | |
| 114 | if (deleted()) { |
| 115 | VLOG(1) << "Deleting file: " << filename(); |
| 116 | WARN_NOT_OK(env()->DeleteFile(filename()), ""); |
| 117 | } |
| 118 | |
| 119 | // The (now expired) weak_ptr remains in 'descriptors_', to be removed by |
| 120 | // the next call to RunDescriptorExpiry(). Removing it here would risk a |
| 121 | // deadlock on recursive acquisition of 'lock_'. |
| 122 | } |
| 123 | |
| 124 | // Insert a pointer to an open file object into the file cache with the |
| 125 | // filename as the cache key. |
nothing calls this directly
no test coverage detected