@@ -50,9 +50,11 @@ describe("project recordings", () => {
5050 await touch ( path . join ( recordingsDir , "recording-123.mp4" ) ) ;
5151 const id = await projectWith ( "Mine" , video ) ;
5252
53- const { owned, keptFor } = await findProjectRecordings ( id , await documents . readAllProjects ( ) , [
54- recordingsDir ,
55- ] ) ;
53+ const { owned, keptFor } = await findProjectRecordings (
54+ id ,
55+ await documents . readAllProjectsReport ( ) ,
56+ [ recordingsDir ] ,
57+ ) ;
5658
5759 expect ( owned ) . toHaveLength ( 1 ) ;
5860 expect ( owned [ 0 ] . files . sort ( ) ) . toEqual ( [ video , ...companions ] . sort ( ) ) ;
@@ -66,19 +68,52 @@ describe("project recordings", () => {
6668 const id = await projectWith ( "Mine" , shared , own ) ;
6769 await projectWith ( "Demo v2" , shared ) ;
6870
69- const { owned, keptFor } = await findProjectRecordings ( id , await documents . readAllProjects ( ) , [
70- recordingsDir ,
71- ] ) ;
71+ const { owned, keptFor } = await findProjectRecordings (
72+ id ,
73+ await documents . readAllProjectsReport ( ) ,
74+ [ recordingsDir ] ,
75+ ) ;
7276
7377 expect ( owned . map ( ( set ) => set . stem ) ) . toEqual ( [ "recording-2" ] ) ;
7478 expect ( keptFor ) . toEqual ( [ "Demo v2" ] ) ;
7579 } ) ;
7680
81+ it ( "keeps every recording while a project file does not parse" , async ( ) => {
82+ const video = await touch ( path . join ( recordingsDir , "recording-9.mp4" ) ) ;
83+ const id = await projectWith ( "Mine" , video ) ;
84+ // Could be a project using recording-9: a newer schema, or a save cut short.
85+ await touch ( path . join ( root , "projects" , "broken.openscreen" ) , "{ not json" ) ;
86+
87+ const { owned, keptFor, unreadable } = await findProjectRecordings (
88+ id ,
89+ await documents . readAllProjectsReport ( ) ,
90+ [ recordingsDir ] ,
91+ ) ;
92+
93+ expect ( owned ) . toEqual ( [ ] ) ;
94+ expect ( keptFor ) . toEqual ( [ ] ) ;
95+ expect ( unreadable ) . toBe ( 1 ) ;
96+ } ) ;
97+
98+ it ( "reports no unreadable projects when it has no recordings to keep" , async ( ) => {
99+ const imported = await touch ( path . join ( elsewhere , "clip.mp4" ) ) ;
100+ const id = await projectWith ( "Imported" , imported ) ;
101+ await touch ( path . join ( root , "projects" , "broken.openscreen" ) , "{ not json" ) ;
102+
103+ const { unreadable } = await findProjectRecordings (
104+ id ,
105+ await documents . readAllProjectsReport ( ) ,
106+ [ recordingsDir ] ,
107+ ) ;
108+
109+ expect ( unreadable ) . toBe ( 0 ) ;
110+ } ) ;
111+
77112 it ( "never owns a video outside the recordings folders" , async ( ) => {
78113 const imported = await touch ( path . join ( elsewhere , "recording-5.mp4" ) ) ;
79114 const id = await projectWith ( "Imported" , imported ) ;
80115
81- const { owned } = await findProjectRecordings ( id , await documents . readAllProjects ( ) , [
116+ const { owned } = await findProjectRecordings ( id , await documents . readAllProjectsReport ( ) , [
82117 recordingsDir ,
83118 ] ) ;
84119
@@ -89,7 +124,7 @@ describe("project recordings", () => {
89124 const video = await touch ( path . join ( recordingsDir , "recording-7.mp4" ) ) ;
90125 const cursor = await touch ( `${ video } .cursor.json` ) ;
91126 const id = await projectWith ( "Mine" , video ) ;
92- const { owned } = await findProjectRecordings ( id , await documents . readAllProjects ( ) , [
127+ const { owned } = await findProjectRecordings ( id , await documents . readAllProjectsReport ( ) , [
93128 recordingsDir ,
94129 ] ) ;
95130
0 commit comments