Comments (6)
Got almost the same issue on the recent version.
2023-10-14 15:29:13,115:P4Transfer:DEBUG: filelogs count: 2369
2023-10-14 15:29:13,117:P4Transfer:DEBUG: src('sync', '//<REMOVEDWSNAME>/...@=54236')
2023-10-14 15:29:13,176:P4Transfer:WARNING: src:sync-msg, //<REMOVEDWSNAME>//...@=54236 - file(s) up-to-date.
2023-10-14 15:29:13,176:P4Transfer:DEBUG: src[]
2023-10-14 15:29:13,187:P4Transfer:ERROR: 'utf-8' codec can't decode byte 0x96 in position 9489: invalid start byte
Traceback (most recent call last):
File "/opt/p4transfer/p4transfer/P4Transfer.py", line 2632, in replicate
num_changes = self.replicate_changes()
File "/opt/p4transfer/p4transfer/P4Transfer.py", line 2448, in replicate_changes
fileRevs, specialMoveRevs, srcFileLogs = self.source.getChange(change['change'])
File "/opt/p4transfer/p4transfer/P4Transfer.py", line 1291, in getChange
chRev.updateDigest()
File "/opt/p4transfer/p4transfer/P4Transfer.py", line 626, in updateDigest
self.fileSize, self.digest = getKTextDigest(self.fixedLocalFile)
File "/opt/p4transfer/p4transfer/P4Transfer.py", line 521, in getKTextDigest
contents = contents.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 9489: invalid start byte
Both servers targets at p4transfer config file is set to none charset, p4charset:
- is empty, as both servers non-unicode
What i've managed to find out, is that file which causes the error is text+k
type (using tag's like $File/$Change/$DateTime/$Revision
) and contains the 0x96 character at the mentioned 9489 position (vim shows it as <96>) alongside with just usual text in it's content. Here is a good explanation of the symbol itself: https://unix.stackexchange.com/a/495650 which describes that it's cp1252 symbol, which makes pain, when trying to decode it as utf-8.
The file itself on target server local filesystem (as well as at source server) is in "unknown-8bit" encoding
root@perforce:/opt/p4transfer# file -bi /opt/p4transfer/transfers/<REMOVED>
text/plain; charset=unknown-8bit
For sure, as a very dirty solution, we can change the file/or re-encode it, however this is not permitted way since we're not owning the code and can't predict any consequences of such change.
Can we just force to encoding="ISO-8859-1"
or latin1
or even better to None
? Or even better to not trying to re-encode any file contents during sync?
Here is all attempts of file opening, only one is a binary:
$ grep -n "open(" p4transfer/P4Transfer.py
469: with open(fname, flags) as fh:
479: with open(fname, flags) as fh:
504: with open(fname, "rb") as f:
2210: with open(fpath, "a") as fh:
2232: with open(fpath, "a") as fh:
2316: with open(self.options.config) as f:
According to https://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html#the-binary-option looks like Binary option is only the reliable way to not corrupt the data.
Why do the encoding/decoding is still in-place? it's something that could lead to data corruption.
Can we introduce an option to allow disabling re-tagging for +k files? (this will allow avoid a kind of such issues)
Any thoughts?
from p4transfer.
This is solved my issue
$ diff -u P4Transfer.py P4Transfer.py.modified.py
--- P4Transfer.py 2023-09-21 16:31:03.163049658 +0000
+++ P4Transfer.py.modified.py 2023-10-14 21:50:24.936233459 +0000
@@ -518,12 +518,12 @@
"Special calculation for ktext files - ignores lines with keywords in them"
contents = readContents(fname)
if python3:
- contents = contents.decode()
+ contents = contents.decode(errors='surrogateescape')
m = hashlib.md5()
# Optimisation to search on whole file
if not re_rcs_keywords.search(contents):
if python3:
- m.update(contents.encode())
+ m.update(contents.encode(errors='surrogateescape'))
else:
m.update(contents)
fileSize = os.path.getsize(fname)
@@ -533,7 +533,7 @@
for line in lines:
if not re_rcs_keywords.search(line):
if python3:
- m.update(line.encode())
+ m.update(line.encode(errors='surrogateescape'))
else:
m.update(line)
fileSize += len(line)
from p4transfer.
@rcowham would you mind to comment on that?
from p4transfer.
Hmmm. Looks OK as a workaround. I wonder if it is better to allow an extra locale setting to be specified?
from p4transfer.
Not sure, that it can provide a reliable solution for keeping data consistent while encoding, since we never sure what exact encoding clients are using until it's not aligned for all developers, which is i believe a rare case. Most common, when several teams using their own approach for encoding settings.
However ability to confiigure this would provide at least instruments for administrators to try manage this on their own.
from p4transfer.
As well for some cases it could can be a good idea to allow restrict (make it configurable) of processsing text+k at all, this will eliminate such kind of issues at all. I believe some of cases (for some setups) not requires to update values of rcs tags while migration.
from p4transfer.
Related Issues (16)
- Issues replicating changed and moved files from other branches
- Issues replicating combined integrate (add) + edit
- Assert when Edit + Move
- Tag a new release HOT 3
- Failure on submit validate when destination is graph depot HOT 1
- UnicodeDecodeError during transfer of first changelist HOT 4
- ignore_files used to filter out directories doesn't work
- Number sign in file name is interpreted as a version number.
- Majority of test suite fails on Windows
- yaml parse syntax?
- Enhance stream creation to not require a manually ordered list.
- Transfer failure due to special characters in path HOT 3
- Transfer halts if all the files from the changelist have been obliterated HOT 4
- email notifications
- Transfer can fail due to P4IGNORE files in depot HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p4transfer.