elementary / switchboard-plug-pantheon-shell

Switchboard Desktop Plug
GNU General Public License v3.0
34 stars 23 forks source link

No backgrounds shown with system backgrounds dir has subdirectories #246

Open worldofpeace opened 3 years ago

worldofpeace commented 3 years ago

Prerequisites

I recalled https://github.com/elementary/switchboard-plug-pantheon-shell/issues/157 but that issue was fixed and there's been no new_for_path -> new_for_uri

Describe the bug

This has been reported on NixOS https://github.com/NixOS/nixpkgs/issues/100293. If there's subdirectories at the system backgrounds directory no wallpapers are loaded from there.

The layout of the system backgrounds directory would be like

/run/current-system/sw/share/backgrounds
  nixos/
  ...bunch of elementary wallpapers

From the output there seems to be nothing of importance.

To Reproduce

Steps to reproduce the behavior:

  1. At your system background directory $XDG_DATA_DIRS/share/backgrounds have a subdirectory with pictures in it
  2. Click on Wallpapers
  3. Just a black background
  4. Now delete that subdirectory and repeat. It's magic and now the wallpapers are there.

I actually did this with no local backgrounds btw.

Expected behavior

It doesn't matter what directory structure at the backgrounds directory is, everything that is an image is loaded.

Screenshots or screen recordings

Screenshot from 2020-10-07 15-38-20

Platform Information

OS: NixOS OS Version: NixOS 20.09 and 21.03-pre-git

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/94184738-no-backgrounds-shown-with-system-backgrounds-dir-has-subdirectories?utm_campaign=plugin&utm_content=tracker%2F57462545&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F57462545&utm_medium=issues&utm_source=github).
worldofpeace commented 3 years ago

I almost want to make a regression test for this, but I don't see any status quo of regression tests in elementary projects.

worldofpeace commented 3 years ago

I looked into bisecting this and realized there's some scenarios I need to test to make sure I could exactly reproduce this. As there's no testing framework for this I had to hack stuff together with nix and to run it manually, but it works pretty nicely to construct and hardcode the backgrounds directory so we don't rely on global state for testing purposes https://github.com/worldofpeace/switchboard-plug-pantheon-shell/commit/4c8fb1508834e2e69d21f71996413da448a30767

These are the scenarios I tested and their results:

:heavy_check_mark: == success, I see wallpapers in the view :red_circle: == fail, I don't see any wallpapers in view

(note I am now testing right off that branch and on master)

To illustrate, this means permutations of the following filesystem layouts don't work

# backgrounds-two-subdirs
backgrounds/
  elementary/
  nixos/

# backgrounds-with-subdir-photos-in-parent
backgrounds/
  photo1,photo2
  nixos/

# backgrounds-with-subdirs-photos-in-parent
backgrounds/
  photo1,photo2
  nixos/
  elementary/
worldofpeace commented 3 years ago

Obviously the bug lies in https://github.com/elementary/switchboard-plug-pantheon-shell/blob/master/src/Views/Wallpaper.vala#L327, I just need to add some debug output so I can see what conditional logic it's jumping into in the three failing scenarios.