Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions frontend/src/components/CloseIcon.svelte

This file was deleted.

19 changes: 0 additions & 19 deletions frontend/src/components/ErrorIcon.svelte

This file was deleted.

18 changes: 0 additions & 18 deletions frontend/src/components/InfoIcon.svelte

This file was deleted.

18 changes: 0 additions & 18 deletions frontend/src/components/SuccessIcon.svelte

This file was deleted.

66 changes: 0 additions & 66 deletions frontend/src/components/Toast.svelte

This file was deleted.

32 changes: 0 additions & 32 deletions frontend/src/components/Toasts.svelte

This file was deleted.

10 changes: 4 additions & 6 deletions frontend/src/pages/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
try {
await DownloadImages();
} catch (e) {
console.log(e);
MessageDialog(e);
} finally {
const result = await GetDownloadedImages();
Expand All @@ -47,7 +46,7 @@
images = result ?? [];
isLoading = false;
} catch (e) {
MessageDialog(e);
// MessageDialog(e);
} finally {
isLoading = false;
}
Expand Down Expand Up @@ -88,11 +87,10 @@
</div>
{/if}
{#if isLoading}
<div class="mx-auto w-48 h-screen flex justify-center items-center">
<img src={LoaderImage} alt="" />
<div class="mx-auto mt-10 flex justify-center items-center">
<img src={LoaderImage} alt="" width="50" />
<h4 class="font-bold">Processing...</h4>
</div>
{:else}
<ListImages {images} />
{/if}
<ListImages {images} />
</div>
4 changes: 2 additions & 2 deletions frontend/src/pages/Setting.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@
>,
<span
class="underline"
on:click={() => setImageCategory('africa')}
on:keydown={() => setImageCategory('africa')}>africa</span
on:click={() => setImageCategory('abstract')}
on:keydown={() => setImageCategory('abstract')}>abstract</span
>
</div>
</div>
Expand Down
20 changes: 11 additions & 9 deletions internal/api/unsplash.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,26 @@ func (u *UnleaseService) GetImages(imgConf ImageConfig) error {
parts := strings.Split(path, "/")
username := parts[len(parts)-1]

go (func() {
go (func(u string, k int, uname string) {
defer wg.Done()
if err := download(ctx, v.Urls.Full, key, imagePath, username); err != nil {
if err := download(ctx, u, k, imagePath, uname); err != nil {
errCh <- err
}
})()
})(v.Urls.Full, key, username)
}
wg.Wait()
close(errCh)

select {
case err := <-errCh:
for err := range errCh {
return err
default:
return nil
}
return nil
// select {
// case err := <-errCh:
// return err
// default:
// return nil
// }
}

func getImage(ctx context.Context, url string) ([]Image, error) {
Expand Down Expand Up @@ -136,7 +140,6 @@ func getImage(ctx context.Context, url string) ([]Image, error) {
}

func download(ctx context.Context, image string, index int, IMAGE_DIR string, upr string) error {

req, err := http.NewRequestWithContext(ctx, http.MethodGet, image, nil)
if err != nil {
return err
Expand All @@ -159,7 +162,6 @@ func download(ctx context.Context, image string, index int, IMAGE_DIR string, up
fmt.Println(info)

f, err := os.Create(fn)
// fmt.Sprintf("%s/%v.jpg", IMAGE_DIR, index))
if err != nil {
return err
}
Expand Down
8 changes: 3 additions & 5 deletions scheduler/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,9 @@ func main() {
}

func scheduleDownloadImages(c api.ImageConfig) error {

fmt.Println(c)
// internal.FetchImages(c)

println("Hello, world my people")
if err := internal.FetchImages(c); err != nil {
return err
}
return nil
}

Expand Down
Loading