aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-05-16 09:28:18 +0200
committerChocobozzz <me@florianbigard.com>2018-05-16 09:42:56 +0200
commit2efd32f697549c59337db5177a93749af8e605d8 (patch)
tree42adaa4bb67b6aa48dcd4fb660616fb37b611573 /client
parent17c49e60b367868c80f44b9921793dc3a2d9adaa (diff)
downloadPeerTube-2efd32f697549c59337db5177a93749af8e605d8.tar.gz
PeerTube-2efd32f697549c59337db5177a93749af8e605d8.tar.zst
PeerTube-2efd32f697549c59337db5177a93749af8e605d8.zip
Fix updating video tags to empty field
Diffstat (limited to 'client')
-rw-r--r--client/src/app/shared/misc/utils.ts5
-rw-r--r--client/src/app/videos/+video-edit/shared/video-edit.component.ts2
-rw-r--r--client/src/assets/player/peertube-chunk-store.ts59
3 files changed, 41 insertions, 25 deletions
diff --git a/client/src/app/shared/misc/utils.ts b/client/src/app/shared/misc/utils.ts
index b5bf99be2..b9aa223cf 100644
--- a/client/src/app/shared/misc/utils.ts
+++ b/client/src/app/shared/misc/utils.ts
@@ -66,6 +66,11 @@ function objectToFormData (obj: any, form?: FormData, namespace?: string) {
66 66
67 if (obj[key] === undefined) continue 67 if (obj[key] === undefined) continue
68 68
69 if (Array.isArray(obj[key]) && obj[key].length === 0) {
70 fd.append(key, null)
71 continue
72 }
73
69 if (obj[key] !== null && typeof obj[ key ] === 'object' && !(obj[ key ] instanceof File)) { 74 if (obj[key] !== null && typeof obj[ key ] === 'object' && !(obj[ key ] instanceof File)) {
70 objectToFormData(obj[ key ], fd, key) 75 objectToFormData(obj[ key ], fd, key)
71 } else { 76 } else {
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
index af4438bd2..d4567e26c 100644
--- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts
@@ -80,7 +80,7 @@ export class VideoEditComponent implements OnInit {
80 this.form.addControl('licence', new FormControl('', VIDEO_LICENCE.VALIDATORS)) 80 this.form.addControl('licence', new FormControl('', VIDEO_LICENCE.VALIDATORS))
81 this.form.addControl('language', new FormControl('', VIDEO_LANGUAGE.VALIDATORS)) 81 this.form.addControl('language', new FormControl('', VIDEO_LANGUAGE.VALIDATORS))
82 this.form.addControl('description', new FormControl('', VIDEO_DESCRIPTION.VALIDATORS)) 82 this.form.addControl('description', new FormControl('', VIDEO_DESCRIPTION.VALIDATORS))
83 this.form.addControl('tags', new FormControl('')) 83 this.form.addControl('tags', new FormControl([]))
84 this.form.addControl('thumbnailfile', new FormControl('')) 84 this.form.addControl('thumbnailfile', new FormControl(''))
85 this.form.addControl('previewfile', new FormControl('')) 85 this.form.addControl('previewfile', new FormControl(''))
86 this.form.addControl('support', new FormControl('', VIDEO_SUPPORT.VALIDATORS)) 86 this.form.addControl('support', new FormControl('', VIDEO_SUPPORT.VALIDATORS))
diff --git a/client/src/assets/player/peertube-chunk-store.ts b/client/src/assets/player/peertube-chunk-store.ts
index 84fbaf146..e14e31c04 100644
--- a/client/src/assets/player/peertube-chunk-store.ts
+++ b/client/src/assets/player/peertube-chunk-store.ts
@@ -155,17 +155,17 @@ export class PeertubeChunkStore extends EventEmitter {
155 this.cleanerInterval = null 155 this.cleanerInterval = null
156 } 156 }
157 157
158 if (this.db) {
159 await this.db.close()
160
161 await this.dropDatabase(this.databaseName)
162 }
163
158 if (this.expirationDB) { 164 if (this.expirationDB) {
159 await this.expirationDB.close() 165 await this.expirationDB.close()
160 this.expirationDB = null 166 this.expirationDB = null
161 } 167 }
162 168
163 if (this.db) {
164 console.log('Destroying IndexDB database %s.', this.databaseName)
165 await this.db.close()
166 await this.db.delete()
167 }
168
169 return cb() 169 return cb()
170 } catch (err) { 170 } catch (err) {
171 console.error('Cannot destroy peertube chunk store.', err) 171 console.error('Cannot destroy peertube chunk store.', err)
@@ -181,31 +181,42 @@ export class PeertubeChunkStore extends EventEmitter {
181 }, PeertubeChunkStore.CLEANER_INTERVAL_MS) 181 }, PeertubeChunkStore.CLEANER_INTERVAL_MS)
182 } 182 }
183 183
184 private checkExpiration () { 184 private async checkExpiration () {
185 this.expirationDB.transaction('rw', this.expirationDB.databases, async () => { 185 let databasesToDeleteInfo: { name: string }[] = []
186 // Update our database expiration since we are alive
187 await this.expirationDB.databases.put({
188 name: this.databaseName,
189 expiration: new Date().getTime() + PeertubeChunkStore.CLEANER_EXPIRATION_MS
190 })
191 186
192 const now = new Date().getTime() 187 try {
193 const databasesToDeleteInfo = await this.expirationDB.databases.where('expiration').below(now).toArray() 188 await this.expirationDB.transaction('rw', this.expirationDB.databases, async () => {
189 // Update our database expiration since we are alive
190 await this.expirationDB.databases.put({
191 name: this.databaseName,
192 expiration: new Date().getTime() + PeertubeChunkStore.CLEANER_EXPIRATION_MS
193 })
194 194
195 for (const databaseToDeleteInfo of databasesToDeleteInfo) { 195 const now = new Date().getTime()
196 await this.dropDatabase(databaseToDeleteInfo.name) 196 databasesToDeleteInfo = await this.expirationDB.databases.where('expiration').below(now).toArray()
197 })
198 } catch (err) {
199 console.error('Cannot update expiration of fetch expired databases.', err)
200 }
197 201
198 await this.expirationDB.databases.where({ name: databaseToDeleteInfo.name }).delete() 202 for (const databaseToDeleteInfo of databasesToDeleteInfo) {
199 } 203 await this.dropDatabase(databaseToDeleteInfo.name)
200 }).catch(err => console.error('Cannot check expiration.', err)) 204 }
201 } 205 }
202 206
203 private dropDatabase (databaseName: string) { 207 private async dropDatabase (databaseName: string) {
204 const dbToDelete = new ChunkDatabase(databaseName) 208 const dbToDelete = new ChunkDatabase(databaseName)
209 console.log('Destroying IndexDB database %s.', databaseName)
205 210
206 console.log('Deleting %s.', databaseName) 211 try {
207 return dbToDelete.delete() 212 await dbToDelete.delete()
208 .catch(err => console.error('Cannot delete %s.', databaseName)) 213
214 await this.expirationDB.transaction('rw', this.expirationDB.databases, () => {
215 return this.expirationDB.databases.where({ name: databaseName }).delete()
216 })
217 } catch (err) {
218 console.error('Cannot delete %s.', databaseName, err)
219 }
209 } 220 }
210 221
211 private nextTick (cb, err, val?) { 222 private nextTick (cb, err, val?) {