import { filesystem } from '@oliveai/ldk';
// Here we're declaring the downloads folder, but this can be chosen by the
// user using the Dropzone component in a Whisper
const downloadsFolder = '/Users/username/Downloads';
filesystem.listenDir(downloadsFolder, async (fileEvent) => {
const { action, info } = fileEvent;
// If a file was "created" in this directory
if (action === 'Create' && info) {
const { name: fileName } = info;
// If the file is a zip file, unzip it
if (fileName.endsWith('.zip')) {
const zipFilePath = await filesystem.join([downloadsFolder, fileName]);
// Unzip the contents to the Downloads folder
await filesystem.unzip(zipFilePath, downloadsFolder);
// Delete the zip file after unzipping
await filesystem.remove(zipFilePath);