Skip to content

Commit

Permalink
make it work on Windows
Browse files Browse the repository at this point in the history
this was upsettingly easy.  however, it requires a trivial patch to
reFUSE to be merged and released:
pleiszenburg/refuse#29
  • Loading branch information
cdanis committed Jul 19, 2020
1 parent 2b41847 commit 49f6288
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ cookies = ['d=wpwQ4182w08qxmE4YP0gvlMb2L...']

That's all you need. All Slacks you logged into will be autodetected.

On Windows, your mountpoint should be a drive letter:
```toml
[emojifs]
mountpoint = 'E:'
```

### A comprehensive configuration
There are a few niceties available:
```toml
Expand Down
3 changes: 2 additions & 1 deletion emojifs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def main():
'overrides mountpoint from config.')
p.add_argument('-f', '--foreground', help='If set, stay in the foreground.', default=False)
p.add_argument('-c', '--config', help='Path to your config file with secrets',
default=os.path.expanduser("~/.emojifs.toml"), type=argparse.FileType('r'))
default=os.path.join(os.path.expanduser("~"), ".emojifs.toml"),
type=argparse.FileType('r'))
p.add_argument('-v', '--verbose', action='count', default=0,
help='Verbosity (-v, -vv, etc). Higher verbosities will log all HTTP traffic '
'(NB: at higher levels, this will log your auth secrets!)')
Expand Down
6 changes: 4 additions & 2 deletions emojifs/muxer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import refuse.high as fuse
from logzero import logger

import emojifs.utils as utils


class Muxer(fuse.LoggingMixIn, fuse.Operations):
def __init__(self, map):
Expand Down Expand Up @@ -80,8 +82,8 @@ def getattr(self, path, *args, **kwargs):
return dict(
st_mode=stat.S_IFDIR | 0o555,
st_nlink=2,
st_uid=os.getuid(),
st_gid=os.getgid(),
st_uid=utils.getuid(),
st_gid=utils.getgid(),
)
# Delegate to mountpoints their / and below.
try:
Expand Down
12 changes: 6 additions & 6 deletions emojifs/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ def getattr(self, path, fh):
st_ctime=min([e['created'] for e in emojis.values()]),
st_atime=time.time(),
st_nlink=2,
st_uid=os.getuid(),
st_gid=os.getgid(),
st_uid=emojifs.utils.getuid(),
st_gid=emojifs.utils.getgid(),
)

if path in self._write_buffers:
Expand All @@ -234,8 +234,8 @@ def getattr(self, path, fh):
st_ctime=time.time(),
st_mtime=time.time(),
st_nlink=1,
st_uid=os.getuid(),
st_gid=os.getgid(),
st_uid=emojifs.utils.getuid(),
st_gid=emojifs.utils.getgid(),
st_size=len(self._write_buffers[path].getbuffer())
)

Expand All @@ -251,8 +251,8 @@ def getattr(self, path, fh):
st_ctime=e['created'],
st_atime=time.time(),
st_nlink=1,
st_uid=os.getuid(),
st_gid=os.getgid(),
st_uid=emojifs.utils.getuid(),
st_gid=emojifs.utils.getgid(),
st_size=(self._get_content_length(e['url']) if self._real_sizes else 256*1024),
)

Expand Down
9 changes: 9 additions & 0 deletions emojifs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@

from emojifs import __version__, __repository__

import os

def set_user_agent(x):
"""Sets a reasonable User-Agent. x should be a Request headers-like object."""
x['User-Agent'] = f"emojifs/{__version__} ({__repository__}) {x['User-Agent']}"

def getuid():
"""Windows doesn't have os.getuid; WinFsp is happy with -1 though."""
return os.getuid() if hasattr(os, 'getuid') else -1

def getgid():
"""Windows doesn't have os.getgid; WinFsp is happy with -1 though."""
return os.getgid() if hasattr(os, 'getgid') else -1

0 comments on commit 49f6288

Please sign in to comment.