Retry file deletion if it fails

The file deletion could fail if it is still held by the web server.

This CL adds retry logic to retry the deletion.

Closes #533.

Change-Id: Ib42ed8db11f32897a29e3b58c1be89d05f5dd034
This commit is contained in:
KongQun Yang 2018-12-14 17:02:13 -08:00
parent 5bf8ad5ed5
commit 6d6db76c80
2 changed files with 10 additions and 2 deletions

View File

@ -636,7 +636,11 @@ void MediaPlaylist::RemoveOldSegment(int64_t start_time) {
while (segments_to_be_removed_.size() > while (segments_to_be_removed_.size() >
hls_params_.preserved_segments_outside_live_window) { hls_params_.preserved_segments_outside_live_window) {
VLOG(2) << "Deleting " << segments_to_be_removed_.front(); VLOG(2) << "Deleting " << segments_to_be_removed_.front();
File::Delete(segments_to_be_removed_.front().c_str()); if (!File::Delete(segments_to_be_removed_.front().c_str())) {
LOG(WARNING) << "Failed to delete " << segments_to_be_removed_.front()
<< "; Will retry later.";
break;
}
segments_to_be_removed_.pop_front(); segments_to_be_removed_.pop_front();
} }
} }

View File

@ -500,7 +500,11 @@ void Representation::RemoveSegments(int64_t start_time,
while (segments_to_be_removed_.size() > while (segments_to_be_removed_.size() >
mpd_options_.mpd_params.preserved_segments_outside_live_window) { mpd_options_.mpd_params.preserved_segments_outside_live_window) {
VLOG(2) << "Deleting " << segments_to_be_removed_.front(); VLOG(2) << "Deleting " << segments_to_be_removed_.front();
File::Delete(segments_to_be_removed_.front().c_str()); if (!File::Delete(segments_to_be_removed_.front().c_str())) {
LOG(WARNING) << "Failed to delete " << segments_to_be_removed_.front()
<< "; Will retry later.";
break;
}
segments_to_be_removed_.pop_front(); segments_to_be_removed_.pop_front();
} }
} }