Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix defaults for safeties and better handle xattrs

  • Loading branch information...
commit a84d5c8d273d59f36482f88b9622e36370b48fdc 1 parent 03056a6
@ioanrogers authored
Showing with 20 additions and 10 deletions.
  1. +16 −6 lib/App/SimplenoteSync.pm
  2. +4 −4 lib/App/SimplenoteSync/Note.pm
View
22 lib/App/SimplenoteSync.pm
@@ -60,7 +60,7 @@ has [ 'no_server_updates', 'no_local_updates' ] => (
is => 'ro',
isa => 'Bool',
required => 1,
- default => 1,
+ default => 0,
);
has logger => (
@@ -142,13 +142,19 @@ sub _write_note_metadata {
$self->logger->debugf( 'Writing note metadata for [%s]', $note->file->basename );
# XXX only write if changed? Add a dirty attr?
- # XXX strip empty tags?
+ # should always be a key
my $metadata = {
'simplenote.key' => $note->key,
- 'simplenote.tags' => join( ',', @{ $note->tags } ),
- 'simplenote.systemtags' => join( ',', @{ $note->systemtags } ),
};
+ if ($note->has_systags) {
+ $metadata->{'simplenote.systemtags'} = $note->join_systags(',');
+ }
+
+ if ($note->has_tags) {
+ $metadata->{'simplenote.tags'} = $note->join_tags(',');
+ }
+
foreach my $key ( keys $metadata ) {
setfattr( $note->file, $key, $metadata->{$key} )
or $self->logger->errorf( 'Error writing note metadata for [%s]', $note->file->basename );
@@ -230,6 +236,12 @@ sub _merge_local_and_remote_lists {
my ( $self, $remote_notes ) = @_;
$self->logger->debug( "Comparing local and remote lists" );
+
+ # XXX what about notes which were deleted on the server, and are to be restored
+ # from local files? i.e key set locally, not existent remotely? How to tell
+ # if the file SHOULD be trashed? User option, perhaps --restore
+
+ # TODO check for tag changes, which don't change date
while ( my ( $key, $note ) = each $remote_notes ) {
if ( exists $self->notes->{$key} ) {
@@ -323,8 +335,6 @@ sub _process_local_notes {
if ( !$self->_read_note_metadata( $note ) ) {
# don't have a key for it, assume is new
- # we could attempt to identify file remotely based on title
- # later on, but we don't
$self->_put_note( $note );
$self->_write_note_metadata( $note );
$self->stats->{new_local}++;
View
8 lib/App/SimplenoteSync/Note.pm
@@ -15,7 +15,7 @@ has file => (
is => 'rw',
isa => 'Path::Class::File',
coerce => 1,
- trigger => \&is_markdown,
+ trigger => \&_has_markdown_ext,
);
has file_extension => (
@@ -47,15 +47,15 @@ MooseX::Storage::Engine->add_custom_type_handler(
);
# set the markdown systemtag if the file has a markdown extension
-sub is_markdown {
+sub _has_markdown_ext {
my $self = shift;
# TODO an array of possibilities? e.g. mkdn, markdown, md
# maybe from system mime info?
my $ext = $self->file_extension->{markdown};
- if ( $self->file =~ m/\.$ext$/ ) {
- $self->systemtags( ['markdown'] );
+ if ( $self->file =~ m/\.$ext$/ && !$self->is_markdown) {
+ $self->set_markdown;
}
return 1;
Please sign in to comment.
Something went wrong with that request. Please try again.