@@ -271,17 +271,6 @@ class ConvertCSVProvider : DocumentsProvider() {
271271 }
272272 // END_INCLUDE(query_search_documents)
273273
274- // BEGIN_INCLUDE(open_document_thumbnail)
275- @Throws(FileNotFoundException ::class )
276- override fun openDocumentThumbnail (documentId : String , sizeHint : Point ,
277- signal : CancellationSignal ): AssetFileDescriptor {
278- Log .v(TAG , " openDocumentThumbnail" )
279-
280- val file = getFileForDocId(documentId)
281- val pfd = ParcelFileDescriptor .open(File (" /" ), ParcelFileDescriptor .MODE_READ_ONLY )
282- return AssetFileDescriptor (pfd, 0 , AssetFileDescriptor .UNKNOWN_LENGTH )
283- }
284- // END_INCLUDE(open_document_thumbnail)
285274
286275 // BEGIN_INCLUDE(query_document)
287276 @Throws(FileNotFoundException ::class )
@@ -386,16 +375,18 @@ class ConvertCSVProvider : DocumentsProvider() {
386375 } else {
387376 val options = GetFileOptions ()
388377 var getFileDone = false
389-
378+ var fileNotFound = false
390379 runOnV8Thread {
391380 mSession?.getFile(file.path, options) {
381+ Log .d(TAG , " getFile " + it.value)
392382 if (it.hasValue) {
393- it.value
394383 if (it.value is String ) {
395384 outputFile.writeText(it.value as String )
396385 } else {
397386 outputFile.writeBytes(it.value as ByteArray )
398387 }
388+ } else {
389+ fileNotFound = true
399390 }
400391 getFileDone = true
401392 }
@@ -405,6 +396,10 @@ class ConvertCSVProvider : DocumentsProvider() {
405396 Thread .sleep(500 )
406397 }
407398
399+ if (fileNotFound) {
400+ throw FileNotFoundException (file.path)
401+ }
402+
408403 return ParcelFileDescriptor .open(outputFile, accessMode)
409404 }
410405 }
@@ -416,8 +411,7 @@ class ConvertCSVProvider : DocumentsProvider() {
416411 override fun createDocument (documentId : String , mimeType : String , displayName : String ): String {
417412 Log .v(TAG , " createDocument" )
418413
419- val parent = getFileForDocId(documentId)
420- val file = GaiaFile (parent!! .path + " /" + displayName, false )
414+ val file = GaiaFile (displayName, false )
421415 try {
422416 // TODO create file
423417 } catch (e: IOException ) {
@@ -528,7 +522,7 @@ class ConvertCSVProvider : DocumentsProvider() {
528522
529523 if (mimeType.startsWith(" image/" )) {
530524 // Allow the image to be represented by a thumbnail rather than an icon
531- flags = flags or Document .FLAG_SUPPORTS_THUMBNAIL
525+ flags = flags // TODO support Document.FLAG_SUPPORTS_THUMBNAIL
532526 }
533527
534528 val row = result.newRow()
@@ -553,12 +547,11 @@ class ConvertCSVProvider : DocumentsProvider() {
553547 */
554548 @Throws(FileNotFoundException ::class )
555549 private fun getFileForDocId (docId : String ): GaiaFile ? {
556- var target = mBaseDir
557550 if (docId == ROOT ) {
558- return target
551+ return mBaseDir
559552 }
560553
561- target = GaiaFile (docId, false )
554+ val target = GaiaFile (docId, false )
562555 return target
563556
564557 }
0 commit comments