Mercurial > hg > orthanc
comparison Core/Compression/ZipWriter.cpp @ 3181:6fd38327e777
Fix issue #130 (Orthanc failed to start when /tmp partition was full)
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 31 Jan 2019 15:33:27 +0100 |
parents | 972cc98959a3 |
children | 5d1f5984dc41 |
comparison
equal
deleted
inserted
replaced
3180:07a2f637b76d | 3181:6fd38327e777 |
---|---|
146 pimpl_->file_ = zipOpen(path_.c_str(), mode); | 146 pimpl_->file_ = zipOpen(path_.c_str(), mode); |
147 } | 147 } |
148 | 148 |
149 if (!pimpl_->file_) | 149 if (!pimpl_->file_) |
150 { | 150 { |
151 LOG(ERROR) << "Cannot create new ZIP archive: " << path_; | |
151 throw OrthancException(ErrorCode_CannotWriteFile); | 152 throw OrthancException(ErrorCode_CannotWriteFile); |
152 } | 153 } |
153 } | 154 } |
154 | 155 |
155 void ZipWriter::SetOutputPath(const char* path) | 156 void ZipWriter::SetOutputPath(const char* path) |
167 void ZipWriter::SetCompressionLevel(uint8_t level) | 168 void ZipWriter::SetCompressionLevel(uint8_t level) |
168 { | 169 { |
169 if (level >= 10) | 170 if (level >= 10) |
170 { | 171 { |
171 throw OrthancException(ErrorCode_ParameterOutOfRange, | 172 throw OrthancException(ErrorCode_ParameterOutOfRange, |
172 "ZIP compression level must be between 0 (no compression) and 9 (highest compression)"); | 173 "ZIP compression level must be between 0 (no compression) " |
174 "and 9 (highest compression)"); | |
173 } | 175 } |
174 | 176 |
175 Close(); | 177 Close(); |
176 compressionLevel_ = level; | 178 compressionLevel_ = level; |
177 } | 179 } |
206 compressionLevel_); | 208 compressionLevel_); |
207 } | 209 } |
208 | 210 |
209 if (result != 0) | 211 if (result != 0) |
210 { | 212 { |
213 LOG(ERROR) << "Cannot add new file inside ZIP archive: " << path; | |
211 throw OrthancException(ErrorCode_CannotWriteFile); | 214 throw OrthancException(ErrorCode_CannotWriteFile); |
212 } | 215 } |
213 | 216 |
214 hasFileInZip_ = true; | 217 hasFileInZip_ = true; |
215 } | 218 } |
237 { | 240 { |
238 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep); | 241 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep); |
239 | 242 |
240 if (zipWriteInFileInZip(pimpl_->file_, data, bytes)) | 243 if (zipWriteInFileInZip(pimpl_->file_, data, bytes)) |
241 { | 244 { |
245 LOG(ERROR) << "Cannot write data to ZIP archive: " << path_; | |
242 throw OrthancException(ErrorCode_CannotWriteFile); | 246 throw OrthancException(ErrorCode_CannotWriteFile); |
243 } | 247 } |
244 | 248 |
245 data += bytes; | 249 data += bytes; |
246 length -= bytes; | 250 length -= bytes; |
251 void ZipWriter::SetAppendToExisting(bool append) | 255 void ZipWriter::SetAppendToExisting(bool append) |
252 { | 256 { |
253 Close(); | 257 Close(); |
254 append_ = append; | 258 append_ = append; |
255 } | 259 } |
256 | |
257 | |
258 } | 260 } |