|
|
@@ -200,8 +200,19 @@ HlsStreamRecorder.prototype.segmentName = function(seqNo) {
|
|
|
};
|
|
|
|
|
|
HlsStreamRecorder.prototype.flushIndex = function(cb) {
|
|
|
- // TODO: make atomic by writing to temp file & renaming
|
|
|
- fs.writeFile(path.join(this.dst, 'index.m3u8'), this.index, cb);
|
|
|
+ var appendString, indexString = this.index.toString().trim();
|
|
|
+ if (this.lastIndexString && indexString.lastIndexOf(this.lastIndexString, 0) === 0) {
|
|
|
+ var lastLength = this.lastIndexString.length;
|
|
|
+ appendString = indexString.substr(lastLength);
|
|
|
+ }
|
|
|
+ this.lastIndexString = indexString;
|
|
|
+
|
|
|
+ if (appendString) {
|
|
|
+ fs.appendFile(path.join(this.dst, 'index.m3u8'), appendString, cb);
|
|
|
+ } else {
|
|
|
+ fs.writeFile(path.join(this.dst, 'index.m3u8'), indexString, cb);
|
|
|
+ }
|
|
|
+};
|
|
|
|
|
|
HlsStreamRecorder.prototype.recorderForUrl = function(remoteUrl) {
|
|
|
var idx, len = this.recorders.length;
|