| 1216 | |
| 1217 | |
| 1218 | Try<Nothing> FetcherProcess::Cache::adjust( |
| 1219 | const shared_ptr<FetcherProcess::Cache::Entry>& entry) |
| 1220 | { |
| 1221 | CHECK(contains(entry)); |
| 1222 | |
| 1223 | Try<Bytes> size = os::stat::size( |
| 1224 | entry.get()->path().string(), |
| 1225 | os::stat::FollowSymlink::DO_NOT_FOLLOW_SYMLINK); |
| 1226 | |
| 1227 | if (size.isSome()) { |
| 1228 | off_t d = delta(size.get(), entry); |
| 1229 | if (d <= 0) { |
| 1230 | entry->size = size.get(); |
| 1231 | |
| 1232 | releaseSpace(Bytes(d)); |
| 1233 | } else { |
| 1234 | return Error("More cache size now necessary, not adjusting " + |
| 1235 | entry->key); |
| 1236 | } |
| 1237 | } else { |
| 1238 | // This should never be caused by Mesos itself, but cannot be excluded. |
| 1239 | return Error("Fetcher cache file for '" + entry->key + |
| 1240 | "' disappeared from: " + entry->path().string()); |
| 1241 | } |
| 1242 | |
| 1243 | return Nothing(); |
| 1244 | } |
| 1245 | |
| 1246 | |
| 1247 | size_t FetcherProcess::Cache::size() const |