mirror of
https://github.com/SlavikMIPT/tgcloud.git
synced 2025-03-09 15:40:14 +00:00
commit
15a44135e9
3 changed files with 12 additions and 0 deletions
|
@ -828,6 +828,8 @@ class DedupFS(fuse.Fuse): # {{{1
|
||||||
with open(FIFO_PIPE, 'wb') as pipe:
|
with open(FIFO_PIPE, 'wb') as pipe:
|
||||||
os.unlink(FIFO_PIPE)
|
os.unlink(FIFO_PIPE)
|
||||||
pipe.write(self.compress(new_block))
|
pipe.write(self.compress(new_block))
|
||||||
|
# if callable(getattr(pipe, 'flush', None)):
|
||||||
|
# pipe.flush()
|
||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
# self.blocks[digest] = self.compress(new_block)
|
# self.blocks[digest] = self.compress(new_block)
|
||||||
|
|
|
@ -80,13 +80,19 @@ def upload_block(hash_uid):
|
||||||
os.chdir(path_home)
|
os.chdir(path_home)
|
||||||
entity = client.get_entity(client.get_me())
|
entity = client.get_entity(client.get_me())
|
||||||
FIFO = f"upipe_{hash_uid}"
|
FIFO = f"upipe_{hash_uid}"
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
try:
|
try:
|
||||||
os.mkfifo(FIFO)
|
os.mkfifo(FIFO)
|
||||||
except OSError as oe:
|
except OSError as oe:
|
||||||
if oe.errno != errno.EEXIST:
|
if oe.errno != errno.EEXIST:
|
||||||
raise
|
raise
|
||||||
|
messages = client.get_messages(entity, limit=1, search=hash_uid)
|
||||||
with open(FIFO, 'rb') as bytesin:
|
with open(FIFO, 'rb') as bytesin:
|
||||||
|
if len(messages):
|
||||||
|
bytesin.read(1)
|
||||||
|
bytesin.close()
|
||||||
|
return 0
|
||||||
message = client.send_file(entity,
|
message = client.send_file(entity,
|
||||||
file=bytesin,
|
file=bytesin,
|
||||||
caption=f'{hash_uid}',
|
caption=f'{hash_uid}',
|
||||||
|
|
|
@ -375,6 +375,8 @@ class TelegramClientX(TelegramClient):
|
||||||
cdn_decrypter, result = CdnDecrypter.prepare_decrypter(client, self._get_cdn_client(result), result)
|
cdn_decrypter, result = CdnDecrypter.prepare_decrypter(client, self._get_cdn_client(result), result)
|
||||||
else:
|
else:
|
||||||
f.write(result.bytes)
|
f.write(result.bytes)
|
||||||
|
# if callable(getattr(f, 'flush', None)):
|
||||||
|
# f.flush()
|
||||||
offset += part_size
|
offset += part_size
|
||||||
except FileMigrateError as e:
|
except FileMigrateError as e:
|
||||||
__log__.info('File lives in another DC')
|
__log__.info('File lives in another DC')
|
||||||
|
@ -410,6 +412,8 @@ class TelegramClientX(TelegramClient):
|
||||||
for th in download_thread:
|
for th in download_thread:
|
||||||
if th.result and th.result.bytes:
|
if th.result and th.result.bytes:
|
||||||
f.write(th.result.bytes)
|
f.write(th.result.bytes)
|
||||||
|
# if callable(getattr(f, 'flush', None)):
|
||||||
|
# f.flush()
|
||||||
if progress_callback:
|
if progress_callback:
|
||||||
progress_callback(f.tell(), file_size)
|
progress_callback(f.tell(), file_size)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue