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
[TIMOB-23493] Android: #append method in Ti.Filesystem.File #8513
Conversation
@@ -135,6 +134,19 @@ public boolean getWritable() | |||
} | |||
|
|||
@Kroll.method | |||
public boolean append(Object data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use tabs
return flagSymbolicLink; | ||
} | ||
|
||
public boolean append(Object data) throws IOException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use tabs
It's best to not modify the original formatting of the files you are making changes to; it's hard to review as I cannot distinguish the original code from the changes you have made. |
@fmerzadyan My comments from #8471 still apply. Appending using writers is incorrect and wasteful in terms of performance as well as may transform the contents. Please just copy bytes (for File) as you do with TiBlob. Also, please try to avoid closing and re-opening new PRs for the same code/ticket. We lose history of the reviews and it becomes difficult to track between ticket and correct PR. |
942370a
to
162600d
Compare
@fmerzadyan There's a merge conflict that needs to be resolved; looks like somehow one of Gary's commits made it into your branch; and lastly, we need to update the yaml docs to indicate that append is now supported on android (apidoc/Titanium/Filesystem/File.yml) |
47f0e1d
to
a7bb5a0
Compare
…hod in TiFileProxy. updated yml.
a7bb5a0
to
8e088f9
Compare
@@ -95,6 +97,71 @@ public boolean isWriteable() | |||
return file.canWrite(); | |||
} | |||
|
|||
@Override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just make use of the write
methods that already exist with an append
flag?
@Override
public boolean append(Object data) throws IOException
{
try {
if (data instanceof String) {
write((String) data, true);
} else if (data instanceof TiFileProxy) {
// write((TiFileProxy) data, true); // implement an append flag into this
} else if (data instanceof TiBlob) {
write((TiBlob) data, true);
}
return true;
} catch (IOException e) {
Log.e(TAG, "Error appending: ", e);
}
return false;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're going that way then it would just be better to edit TiFileProxy instead because less changes would need to be made.
4c8d527
to
035db6d
Compare
9a9f521
to
83b5406
Compare
@@ -139,6 +138,13 @@ public boolean getWritable() | |||
} | |||
|
|||
@Kroll.method | |||
public boolean append(Object data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just do this, there's no need for any other changes.
@Kroll.method
public boolean append(Object data)
{
return write(new Object[]{data, true});
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was only 1 write method. The original write method had only one argument (Object[] args). I changed it so that it could take in append argument which is necessary. It keeps the original write exposed, the new write method not exposed and append is exposed too. But I'll be sure to change this one line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Titanium.Filesystem.write should already be exposed with the optional append
parameter, so you can just make use of that 👍
{ | ||
try { | ||
|
||
if (args != null && args.length > 0) { | ||
boolean append = false; | ||
if (args.length > 1 && args[1] instanceof Boolean) { | ||
append = ((Boolean)args[1]).booleanValue(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The args
array contains the append
Boolean, so there's no need to redefine it as a parameter. Which is why these changes aren't necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I removed that, my mistake.
22b1ba3
to
130a0cc
Compare
CR: PASS 👍 |
test this please |
JIRA: https://jira.appcelerator.org/browse/timob-23493