comparison OrthancServer/Sources/OrthancWebDav.cpp @ 4245:c70df925151e

RequestOrigin_WebDav
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 10 Oct 2020 11:23:11 +0200
parents 416c35da7d25
children 6c3721ff284c
comparison
equal deleted inserted replaced
4244:416c35da7d25 4245:c70df925151e
1197 if (obj.get() != NULL) 1197 if (obj.get() != NULL)
1198 { 1198 {
1199 that->Upload(reinterpret_cast<const SingleValueObject<std::string>&>(*obj).GetValue()); 1199 that->Upload(reinterpret_cast<const SingleValueObject<std::string>&>(*obj).GetValue());
1200 lastModification = GetNow(); 1200 lastModification = GetNow();
1201 } 1201 }
1202 else if (GetNow() - lastModification > boost::posix_time::seconds(10)) 1202 else if (GetNow() - lastModification > boost::posix_time::seconds(30))
1203 { 1203 {
1204 // After every 10 seconds of inactivity, remove the empty folders 1204 /**
1205 * After every 30 seconds of inactivity, remove the empty
1206 * folders. This delay is needed to avoid removing
1207 * just-created folders before the remote WebDAV has time to
1208 * write files into it.
1209 **/
1205 LOG(INFO) << "Cleaning up the empty WebDAV upload folders"; 1210 LOG(INFO) << "Cleaning up the empty WebDAV upload folders";
1206 that->uploads_.RemoveEmptyFolders(); 1211 that->uploads_.RemoveEmptyFolders();
1207 lastModification = GetNow(); 1212 lastModification = GetNow();
1208 } 1213 }
1209 } 1214 }
1221 std::string content; 1226 std::string content;
1222 boost::posix_time::ptime time; 1227 boost::posix_time::ptime time;
1223 if (uploads_.GetFileContent(mime, content, time, uri)) 1228 if (uploads_.GetFileContent(mime, content, time, uri))
1224 { 1229 {
1225 DicomInstanceToStore instance; 1230 DicomInstanceToStore instance;
1226 // instance.SetOrigin(DicomInstanceOrigin_WebDav); // TODO 1231 instance.SetOrigin(DicomInstanceOrigin::FromWebDav());
1227 instance.SetBuffer(content.c_str(), content.size()); 1232 instance.SetBuffer(content.c_str(), content.size());
1228 1233
1229 bool success = false; 1234 bool success = false;
1230 1235
1231 try 1236 try
1233 std::string publicId; 1238 std::string publicId;
1234 StoreStatus status = context_.Store(publicId, instance, StoreInstanceMode_Default); 1239 StoreStatus status = context_.Store(publicId, instance, StoreInstanceMode_Default);
1235 if (status == StoreStatus_Success || 1240 if (status == StoreStatus_Success ||
1236 status == StoreStatus_AlreadyStored) 1241 status == StoreStatus_AlreadyStored)
1237 { 1242 {
1238 LOG(INFO) << "Successfully imported DICOM instance from WebDAV: " << path << " (Orthanc ID: " << publicId << ")"; 1243 LOG(INFO) << "Successfully imported DICOM instance from WebDAV: "
1244 << path << " (Orthanc ID: " << publicId << ")";
1239 success = true; 1245 success = true;
1240 } 1246 }
1241 } 1247 }
1242 catch (OrthancException& e) 1248 catch (OrthancException& e)
1243 { 1249 {