1- import { BaseDirectory , readDir , type ReadFileOptions , type DirEntry , readTextFileLines , type WatchEvent , type UnwatchFn } from '@tauri-apps/plugin-fs' ;
1+ import { BaseDirectory , readDir , type DirEntry , type WatchEvent , type UnwatchFn } from '@tauri-apps/plugin-fs' ;
22import { watch } from '@tauri-apps/plugin-fs'
33import relativeTime from 'dayjs/plugin/relativeTime'
44import localizedFormat from 'dayjs/plugin/localizedFormat'
@@ -7,7 +7,8 @@ import { LAST_STARTED_DATE, LAST_UPDATED, PROGRAM_FOLDER } from '../constants';
77import { getStorageItem , saveStorageItem } from '../utils/storage' ;
88import { invoke } from '@tauri-apps/api/core' ;
99import { join } from '@tauri-apps/api/path' ;
10- import { info } from '@tauri-apps/plugin-log' ;
10+ import { error , info } from '@tauri-apps/plugin-log' ;
11+ import { platform } from '@tauri-apps/plugin-os' ;
1112
1213export const useFileUpload = ( ) => {
1314 dayjs . extend ( relativeTime )
@@ -94,7 +95,12 @@ export const useFileUpload = () => {
9495 }
9596
9697 const isModifyAnyEvent = ( event : WatchEvent ) : boolean => {
97- return typeof event . type === 'object' && 'modify' in event . type && ( event . type . modify . kind === 'any' || event . type . modify . kind === 'rename' ) ;
98+ const currentPlatform = platform ( ) ;
99+ if ( currentPlatform === 'macos' ) {
100+ return typeof event . type === 'object' && 'modify' in event . type && ( event . type . modify . kind === 'any' || event . type . modify . kind === 'rename' ) ;
101+ } else {
102+ return typeof event . type === 'object' && 'modify' in event . type && event . type . modify . kind === 'any' ;
103+ }
98104 }
99105
100106 const handleUpload = async ( force : boolean = false , event : WatchEvent = null ) => {
@@ -108,6 +114,7 @@ export const useFileUpload = () => {
108114 if ( event && ! isModifyAnyEvent ( event ) ) {
109115 return ;
110116 }
117+ console . log ( { event} )
111118
112119 isProcessing . value = true ;
113120 await saveStorageItem < string > ( LAST_STARTED_DATE , dayjs ( ) . format ( ) ) ;
@@ -123,14 +130,13 @@ export const useFileUpload = () => {
123130
124131 for ( const file of dedupedFiles ) {
125132 info ( `Uploading file: ${ file } at file path: ${ file } ` ) ;
126- const contents = await readBigFile ( file , { baseDir : BaseDirectory . Home } ) ;
127133
128134 try {
129- const message = await invoke ( 'submit_addon_data' , { contents } ) ;
135+ const message = await invoke ( 'submit_addon_data' , { filePath : file } ) ;
130136 info ( `Uploaded file: ${ file } ` ) ;
131137 info ( `API response from ${ file } : ${ message } ` ) ;
132- } catch ( error ) {
133- error ( `File failed to upload! File: ${ file } ; Return: ${ error } ` ) ;
138+ } catch ( result ) {
139+ error ( `File failed to upload! File: ${ file } ; Return: ${ result } ` ) ;
134140 await notifications . send ( { title : 'Wowthing Sync' , body : 'An error occurred while uploading. Please try again later.' } ) ;
135141 isProcessing . value = false ;
136142 return ; // Stop the rest of the loop from working
@@ -152,16 +158,6 @@ export const useFileUpload = () => {
152158 return unique ;
153159 }
154160
155- const readBigFile = async ( filePath : string , options ?: ReadFileOptions ) => {
156- const lines = await readTextFileLines ( filePath , options ) ;
157- let fileData = '' ;
158- for await ( const line of lines ) {
159- fileData += line ;
160- }
161-
162- return fileData ;
163- } ;
164-
165161 onMounted ( ( ) => {
166162 getLastUpdated ( ) ;
167163
0 commit comments