comparison OrthancFramework/Sources/HttpServer/WebDavStorage.cpp @ 4239:c8754c4c1862

upload DICOM using WebDAV
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Oct 2020 11:38:03 +0200
parents ca2a55a62c81
children 50b0c69b653a
comparison
equal deleted inserted replaced
4238:c007fb7c8395 4239:c8754c4c1862
158 assert(it->second != NULL); 158 assert(it->second != NULL);
159 delete it->second; 159 delete it->second;
160 } 160 }
161 } 161 }
162 162
163 size_t GetSize() const
164 {
165 return files_.size() + subfolders_.size();
166 }
167
163 const boost::posix_time::ptime& GetModificationTime() const 168 const boost::posix_time::ptime& GetModificationTime() const
164 { 169 {
165 return time_; 170 return time_;
166 } 171 }
167 172
325 { 330 {
326 return false; 331 return false;
327 } 332 }
328 } 333 }
329 } 334 }
335
336
337 void RemoveEmptyFolders()
338 {
339 std::list<std::string> emptyFolders;
340
341 for (Subfolders::const_iterator it = subfolders_.begin(); it != subfolders_.end(); ++it)
342 {
343 assert(it->second != NULL);
344 it->second->RemoveEmptyFolders();
345
346 if (it->second->GetSize() == 0)
347 {
348 assert(it->second != NULL);
349 delete it->second;
350
351 emptyFolders.push_back(it->first);
352 }
353 }
354
355 for (std::list<std::string>::const_iterator it = emptyFolders.begin();
356 it != emptyFolders.end(); ++it)
357 {
358 assert(subfolders_.find(*it) != subfolders_.end());
359 subfolders_.erase(*it);
360 }
361 }
330 }; 362 };
331 363
332 364
333 WebDavStorage::StorageFolder* WebDavStorage::LookupParentFolder(const std::vector<std::string>& path) 365 WebDavStorage::StorageFolder* WebDavStorage::LookupParentFolder(const std::vector<std::string>& path)
334 { 366 {
457 489
458 LOG(INFO) << "Deleting from WebDAV bucket: " << Toolbox::FlattenUri(path); 490 LOG(INFO) << "Deleting from WebDAV bucket: " << Toolbox::FlattenUri(path);
459 return root_->DeleteItem(path); 491 return root_->DeleteItem(path);
460 } 492 }
461 } 493 }
494
495
496 void WebDavStorage::RemoveEmptyFolders()
497 {
498 boost::recursive_mutex::scoped_lock lock(mutex_);
499 root_->RemoveEmptyFolders();
500 }
462 } 501 }