Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZIP file as directory support #3

Open
JuniorJPDJ opened this issue Aug 16, 2020 · 7 comments
Open

ZIP file as directory support #3

JuniorJPDJ opened this issue Aug 16, 2020 · 7 comments

Comments

@JuniorJPDJ
Copy link
Contributor

Me and my friends are sharing music with each other, but when we share albums - those are ZIPed.
What if your filesystem could mount those ZIP files as directories in filesystem?
There's very easy to use Zipfile lib in python stdlib.

@wvffle
Copy link

wvffle commented Aug 26, 2020

+1

@JuniorJPDJ
Copy link
Contributor Author

JuniorJPDJ commented Aug 27, 2020

ATM I did workaround, but It's not satisfying ;/

#!/bin/bash

shopt -s nullglob

ID="$1"
DIR="$2"
TGDIR="$DIR/tg"
ZIPDIR="$DIR/zips"

mount_zip(){
    zip="$1"
    zipd="$ZIPDIR/$(basename "$zip")"
    mkdir -p "$zipd"
    echo Mounting $zip
    archivemount -o readonly "$zip" "$zipd"
    echo Mounted $zip
}

mount_zips(){
    for zip in $TGDIR/*.zip; do
        mount_zip "$zip" &
    done
}

cleanup(){
    for dir in $ZIPDIR/*; do
        umount "$dir"
        rmdir "$dir"
    done
}
trap cleanup EXIT

mkdir -p "$TGDIR"
./tgmount.py --all-files --reverse --id $ID --mount "$TGDIR" |&
    while read line; do
        echo tgmount: $line

        if [[ "$line" =~ "Mounting " ]]; then
            sleep 1
            echo Mounted telegram, starting mounting zips.
            mount_zips &
        fi  

        if [[ "$line" =~ "New file: " ]]; then
            mid="$(awk 'match($0, /message_id'\'': [0-9]+?,/) { print substr($0, RSTART + 13, RLENGTH - 14) }' <<< $line)"
            fname="$(echo $TGDIR/$mid\ *)"
            echo New file: $fname
                
            [[ "$fname" = *.zip ]] && mount_zip "$fname"
        fi  
    done

@wvffle
Copy link

wvffle commented Aug 27, 2020

You forgot to mention that https://github.com/cybernoid/archivemount is used to mount the zip files

@JuniorJPDJ
Copy link
Contributor Author

I found project better fitting use case: https://github.com/openscopeproject/ZipROFS
If you'd like to integrate this feature in tgmount - it seems to be pretty good base for your work.
If not, I'll just use this as next layer ;)

@nktknshn
Copy link
Owner

I'm currently working on the the feature :) thank you for the link. It is going to be useful to me

@mockuser404
Copy link

@nktknshn any updates? I see only master branch

@nktknshn
Copy link
Owner

nktknshn commented Feb 2, 2023

I added this feature in the new version of tgmount. Try it out
https://github.com/nktknshn/tgmount-ng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants