manyfold3d / manyfold

A self-hosted digital asset manager for 3d print files.
https://manyfold.app
MIT License
692 stars 45 forks source link

Don't group models in the library root folder #2504

Closed pagdot closed 3 weeks ago

pagdot commented 1 month ago

Is your feature request related to a problem? Please describe.

I organized my 3d models on disk where I only create a folder, if I have multiple files belonging together. So the root folder of my library contains single models and folders with models belonging together. Right now manyfold creates one model for all loose files in the root folder of the library.

Describe the solution you'd like

Be able (maybe configurable) to not group the files in the root folder together

Describe alternatives you've considered

Manually (or using a script) move each loose file to a new folder

Floppy commented 1 month ago

That's interesting, it should ignore them completely. But, it would be a nice addition to get it to treat them all as separate models.

pagdot commented 1 month ago

They show up grouped as ".". So for some reason the ignoring doesn't work for me right now

Floppy commented 1 month ago

Can you pop in a screenshot of the model page that has all your root files in it? Particularly the info section at the side.

pagdot commented 1 month ago

grafik

Can also create a bug for this issue^^

Floppy commented 1 month ago

Huh. How odd. Yeah, I think this might be a bug and a feature request, it shoudn't be doing that.

pagdot commented 1 month ago

I'm no ruby guy, but looking at the source, I've found this line:

 folders_with_changes.delete("/")

https://github.com/manyfold3d/manyfold/blob/main/app/jobs/scan/detect_filesystem_changes_job.rb#L30C1-L30C37

Seems like for some reason, the root folder of the library is called "." on my system and not "/"

Floppy commented 1 month ago

Good spot, that's probably right!

Floppy commented 1 month ago

what filesystem are you using? Could be something to do with that perhaps.

pagdot commented 1 month ago

A few more findings:

$ echo 'File.dirname("abc")' | irb
Switch to inspect mode.
File.dirname("abc")
"."

$ echo 'File.dirname("/abc")' | irb
Switch to inspect mode.
File.dirname("/abc")
"/"

I don't understand everything from the parsing code and don't want to invest the time right now to dig deeper in ruby, but it seems like to have a file group with / as foldername (which will be removed), it is required that the the path of the file starts with /. I'm not sure in what case that would happen because File.glob('**') paths would start without leading slash. Maybe something there I don't understand. Do you have models in the libraries root folder or can put one or two there to verify this behaviour?

what filesystem are you using? Could be something to do with that perhaps.

btrfs. Would expect the file system to not matter from what I know

Because this also a bug, here a few infos about my system:


services:
  manyfold:
    container_name: manyfold
    restart: unless-stopped
    image: lscr.io/linuxserver/manyfold:0.74.2
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - DATABASE_URL=postgresql://manyfold:REDACTED@manyfold-db:5432/manyfold
      - REDIS_URL=redis://manyfold-redis
      - SECRET_KEY_BASE=REDACTED
    volumes:
      - ./config:/config
      - ./libraries/cloud:/libraries/cloud
    networks:
      - default
      - reverse-proxy

  redis:
    container_name: manyfold-redis
    image: redis:7
    restart: always
    networks:
      - default

  db:
    image: postgres:16
    container_name: manyfold-db
    restart: always
    environment:
      POSTGRES_PASSWORD: REDACTED
      POSTGRES_USER: manyfold
      POSTGRES_DB: manyfold
    user: 1000:1000
    volumes:
      - ./db:/var/lib/postgresql/data
    networks:
      - default

networks:
  default:
  reverse-proxy:
    external: true
Floppy commented 1 month ago

Ah, interesting, could be because whether or not it has a leading slash in the library path. What's the actual path you have set in the library? You should be able to see it down the bottom of the settings page.

pagdot commented 1 month ago
/libraries/cloud

This shouldn't matter, because a base path is used:

 Dir.glob(pattern, flags, base: Shellwords.escape(path)).filter { |x| File.file?(File.join(path, x)) }

https://github.com/manyfold3d/manyfold/blob/main/app/models/library.rb#L121C7-L121C104

This should make all paths "local" to the base path and I'm not sure how this would cause the root folder to be /

pagdot commented 1 month ago

Tried to create a simple example (this is on an ext4 disk):

mkdir -p /tmp/rubytest/{a,b/c}
touch /tmp/rubytest/{f,a/fa,b/fb,b/c/fc}
echo 'path="/tmp/rubytest"; Dir.glob("**/*", base: path).filter { |x| File.file?(File.join(path, x)) }.map { |f| "#{File.dirname(f)}: #{File.basename(f)}" }' | irb
Switch to inspect mode.
path="/tmp/rubytest"; Dir.glob("**/*", base: path).filter { |x| File.file?(File.join(path, x)) }.map { |f| "#{File.dirname(f)}: #{File.basename(f)}" }
["a: fa", "b/c: fc", "b: fb", ".: f"]

I don't see how the root folder can be / when using base: path. Pretty sure it is always .

Floppy commented 1 month ago

Hm, you're right, that might be a case that's slipped through the tests and changed when I rewrote the file handling.