Skip to content

Commit

Permalink
Move encryption of filenames to the point where they're transmitted,
Browse files Browse the repository at this point in the history
rather than where they're generated.   Causes a major performance
improvement, as much of the time spent on an incremental backup was
encrypting the filenames.   Does change the directory hash values, so
first backup post this change can be slower than normal.
  • Loading branch information
koldinger committed May 9, 2020
1 parent 33a7374 commit 0a078cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/Tardis/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ def mkFileInfo(dir, name):
return None

if stat.S_ISREG(mode) or stat.S_ISDIR(mode) or stat.S_ISLNK(mode):
name = crypt.encryptFilename(name)
#name = crypt.encryptFilename(name)
finfo = {
'name': name,
'inode': s.st_ino,
Expand Down Expand Up @@ -1091,7 +1091,7 @@ def sendPurge(relative):

def sendDirChunks(path, inode, files):
""" Chunk the directory into dirslice sized chunks, and send each sequentially """
if crypt:
if crypt.encrypting():
path = crypt.encryptPath(path)
message = {
'message': 'DIR',
Expand All @@ -1105,10 +1105,16 @@ def sendDirChunks(path, inode, files):
logger.debug("---- Generating chunk %d ----", chunkNum)
chunkNum += 1
chunk = files[x : x + args.dirslice]

# Encrypt the names before sending them out
if crypt.encrypting():
for i in chunk:
i['name'] = crypt.encryptFilename(i['name'])

message["files"] = chunk
message["last"] = (x + args.dirslice > len(files))
if verbosity > 3:
logger.debug("---- Sending chunk ----")
logger.debug("---- Sending chunk at %d ----", x)
batch = (len(chunk) < args.dirslice)
batchMessage(message, batch=batch)

Expand Down Expand Up @@ -1518,6 +1524,8 @@ def createPrefixPath(root, path):
dirPath = os.path.join(current, d)
st = os.lstat(dirPath)
f = mkFileInfo(current, d)
if crypt.encrypting():
f['name'] = crypt.encryptFilename(f['name'])
if dirPath not in processedDirs:
logger.debug("Sending dir entry for: %s", dirPath)
sendDirEntry(parent, parentDev, [f])
Expand Down
10 changes: 7 additions & 3 deletions tardis-profile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#! /usr/bin/python
# -*- coding: utf-8 -*-

from Tardis import Client
import sys

import sys, os.path
import cProfile
import time

src = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'src')
sys.path.insert(0, src)

from Tardis import Client

name = 'tardis.profile.' + str(int(time.time()))

#sys.exit(Client.main())
Expand Down

0 comments on commit 0a078cb

Please sign in to comment.