File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
src/components/file/media Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -154,10 +154,24 @@ export class MediaRepository extends CommonRepository {
154
154
. apply ( this . hydrate ( ) ) ;
155
155
156
156
const result = await query . first ( ) ;
157
- if ( ! result ) {
158
- throw new ServerException ( 'Failed to save media info' ) ;
157
+ if ( result ) {
158
+ return result . dto ;
159
159
}
160
- return result . dto ;
160
+ if ( input . file ) {
161
+ const exists = await this . getBaseNode ( input . file , 'FileVersion' ) ;
162
+ if ( ! exists ) {
163
+ throw new NotFoundException (
164
+ 'Media could not be saved to nonexistent file' ,
165
+ ) ;
166
+ }
167
+ }
168
+ if ( input . id ) {
169
+ const exists = await this . getBaseNode ( input . id , 'Media' ) ;
170
+ if ( ! exists ) {
171
+ throw new NotFoundException ( 'Media could not be found' ) ;
172
+ }
173
+ }
174
+ throw new ServerException ( 'Failed to save media info' ) ;
161
175
}
162
176
}
163
177
You can’t perform that action at this time.
0 commit comments