40 : value(
"this-hash-value-is-empty")
49 : value(container.getId())
57 return (value != other.
value);
62 return (value == other.
value);
67 return (value < other.
value);
71 : ibrcommon::File(file), _stream(NULL), _lock(mutex)
74 _stream =
new std::ifstream(
getPath().c_str(), ios_base::in | ios_base::binary);
90 : _callback(callback), _path(path), _tasks(), _store_sem(write_buffer), _store_limited(write_buffer > 0), _faulty(false)
99 std::list<ibrcommon::File> files;
102 for (std::list<ibrcommon::File>::iterator iter = files.begin(); iter != files.end(); ++iter)
104 (*iter).remove(
true);
124 Task *t = _tasks.
getnpop(
false);
134 JoinableThread::reset();
144 std::list<ibrcommon::File> files;
147 for (std::list<ibrcommon::File>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
149 if (!(*iter).isSystem() && !(*iter).isDirectory())
162 if (_store_limited) _store_sem.
wait();
165 _tasks.
push(
new StoreDataTask(hash, data) );
190 _tasks.
push(
new RemoveDataTask(hash) );
208 Task *t = _tasks.
get(
true);
211 StoreDataTask &
store =
dynamic_cast<StoreDataTask&
>(*t);
218 std::ofstream stream(destination.
getPath().c_str(), ios::out | ios::binary | ios::trunc);
221 if (!stream.good() || _faulty)
223 std::stringstream ss; ss <<
"unable to open filestream [" << std::strerror(errno) <<
"]";
227 store._container->serialize(stream);
232 if (_store_limited) _store_sem.
post();
238 if (_store_limited) _store_sem.
post();
243 }
catch (
const std::bad_cast&) {
247 RemoveDataTask &
remove =
dynamic_cast<RemoveDataTask&
>(*t);
253 if (!destination.
exists())
263 }
catch (
const std::bad_cast&) {
276 DataStorage::Task::~Task() {}
278 DataStorage::StoreDataTask::StoreDataTask(
const Hash &
h, Container *c)
279 : hash(h), _container(c)
282 DataStorage::StoreDataTask::~StoreDataTask()
286 DataStorage::RemoveDataTask::RemoveDataTask(
const Hash &
h) : hash(h)
289 DataStorage::RemoveDataTask::~RemoveDataTask()